node-switchbot 3.6.6 → 4.0.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/CHANGELOG.md +322 -0
- package/PRODUCTION_READY.md +135 -0
- package/README.md +92 -0
- package/dist/api.d.ts +130 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +286 -0
- package/dist/api.js.map +1 -0
- package/dist/ble.d.ts +116 -0
- package/dist/ble.d.ts.map +1 -0
- package/dist/ble.js +430 -0
- package/dist/ble.js.map +1 -0
- package/dist/devices/base.d.ts +146 -0
- package/dist/devices/base.d.ts.map +1 -0
- package/dist/devices/base.js +324 -0
- package/dist/devices/base.js.map +1 -0
- package/dist/devices/index.d.ts +30 -0
- package/dist/devices/index.d.ts.map +1 -0
- package/dist/devices/index.js +34 -0
- package/dist/devices/index.js.map +1 -0
- package/dist/devices/wo-air-purifier-table.d.ts +8 -0
- package/dist/devices/wo-air-purifier-table.d.ts.map +1 -0
- package/dist/devices/wo-air-purifier-table.js +12 -0
- package/dist/devices/wo-air-purifier-table.js.map +1 -0
- package/dist/devices/wo-air-purifier.d.ts +28 -0
- package/dist/devices/wo-air-purifier.d.ts.map +1 -0
- package/dist/devices/wo-air-purifier.js +105 -0
- package/dist/devices/wo-air-purifier.js.map +1 -0
- package/dist/devices/wo-blind-tilt.d.ts +36 -0
- package/dist/devices/wo-blind-tilt.d.ts.map +1 -0
- package/dist/devices/wo-blind-tilt.js +95 -0
- package/dist/devices/wo-blind-tilt.js.map +1 -0
- package/dist/devices/wo-bulb.d.ts +32 -0
- package/dist/devices/wo-bulb.d.ts.map +1 -0
- package/dist/devices/wo-bulb.js +109 -0
- package/dist/devices/wo-bulb.js.map +1 -0
- package/dist/devices/wo-ceiling-light.d.ts +8 -0
- package/dist/devices/wo-ceiling-light.d.ts.map +1 -0
- package/dist/devices/wo-ceiling-light.js +12 -0
- package/dist/devices/wo-ceiling-light.js.map +1 -0
- package/dist/devices/wo-contact.d.ts +12 -0
- package/dist/devices/wo-contact.d.ts.map +1 -0
- package/dist/devices/wo-contact.js +50 -0
- package/dist/devices/wo-contact.js.map +1 -0
- package/dist/devices/wo-curtain.d.ts +28 -0
- package/dist/devices/wo-curtain.d.ts.map +1 -0
- package/dist/devices/wo-curtain.js +82 -0
- package/dist/devices/wo-curtain.js.map +1 -0
- package/dist/devices/wo-hand.d.ts +24 -0
- package/dist/devices/wo-hand.d.ts.map +1 -0
- package/dist/devices/wo-hand.js +70 -0
- package/dist/devices/wo-hand.js.map +1 -0
- package/dist/devices/wo-hub2.d.ts +12 -0
- package/dist/devices/wo-hub2.d.ts.map +1 -0
- package/dist/devices/wo-hub2.js +48 -0
- package/dist/devices/wo-hub2.js.map +1 -0
- package/dist/devices/wo-hub3.d.ts +8 -0
- package/dist/devices/wo-hub3.d.ts.map +1 -0
- package/dist/devices/wo-hub3.js +12 -0
- package/dist/devices/wo-hub3.js.map +1 -0
- package/dist/devices/wo-humi.d.ts +28 -0
- package/dist/devices/wo-humi.d.ts.map +1 -0
- package/dist/devices/wo-humi.js +91 -0
- package/dist/devices/wo-humi.js.map +1 -0
- package/dist/devices/wo-humi2.d.ts +8 -0
- package/dist/devices/wo-humi2.d.ts.map +1 -0
- package/dist/devices/wo-humi2.js +12 -0
- package/dist/devices/wo-humi2.js.map +1 -0
- package/dist/devices/wo-io-sensor-th.d.ts +8 -0
- package/dist/devices/wo-io-sensor-th.d.ts.map +1 -0
- package/dist/devices/wo-io-sensor-th.js +12 -0
- package/dist/devices/wo-io-sensor-th.js.map +1 -0
- package/dist/devices/wo-keypad.d.ts +13 -0
- package/dist/devices/wo-keypad.d.ts.map +1 -0
- package/dist/devices/wo-keypad.js +46 -0
- package/dist/devices/wo-keypad.js.map +1 -0
- package/dist/devices/wo-leak.d.ts +12 -0
- package/dist/devices/wo-leak.d.ts.map +1 -0
- package/dist/devices/wo-leak.js +46 -0
- package/dist/devices/wo-leak.js.map +1 -0
- package/dist/devices/wo-lock-pro.d.ts +24 -0
- package/dist/devices/wo-lock-pro.d.ts.map +1 -0
- package/dist/devices/wo-lock-pro.js +72 -0
- package/dist/devices/wo-lock-pro.js.map +1 -0
- package/dist/devices/wo-lock.d.ts +20 -0
- package/dist/devices/wo-lock.d.ts.map +1 -0
- package/dist/devices/wo-lock.js +64 -0
- package/dist/devices/wo-lock.js.map +1 -0
- package/dist/devices/wo-plug-mini-jp.d.ts +8 -0
- package/dist/devices/wo-plug-mini-jp.d.ts.map +1 -0
- package/dist/devices/wo-plug-mini-jp.js +12 -0
- package/dist/devices/wo-plug-mini-jp.js.map +1 -0
- package/dist/devices/wo-plug-mini-us.d.ts +24 -0
- package/dist/devices/wo-plug-mini-us.d.ts.map +1 -0
- package/dist/devices/wo-plug-mini-us.js +70 -0
- package/dist/devices/wo-plug-mini-us.js.map +1 -0
- package/dist/devices/wo-presence.d.ts +12 -0
- package/dist/devices/wo-presence.d.ts.map +1 -0
- package/dist/devices/wo-presence.js +48 -0
- package/dist/devices/wo-presence.js.map +1 -0
- package/dist/devices/wo-relay-switch-1.d.ts +24 -0
- package/dist/devices/wo-relay-switch-1.d.ts.map +1 -0
- package/dist/devices/wo-relay-switch-1.js +70 -0
- package/dist/devices/wo-relay-switch-1.js.map +1 -0
- package/dist/devices/wo-relay-switch-1pm.d.ts +8 -0
- package/dist/devices/wo-relay-switch-1pm.d.ts.map +1 -0
- package/dist/devices/wo-relay-switch-1pm.js +12 -0
- package/dist/devices/wo-relay-switch-1pm.js.map +1 -0
- package/dist/devices/wo-remote.d.ts +13 -0
- package/dist/devices/wo-remote.d.ts.map +1 -0
- package/dist/devices/wo-remote.js +45 -0
- package/dist/devices/wo-remote.js.map +1 -0
- package/dist/devices/wo-sensor-th-plus.d.ts +8 -0
- package/dist/devices/wo-sensor-th-plus.d.ts.map +1 -0
- package/dist/devices/wo-sensor-th-plus.js +12 -0
- package/dist/devices/wo-sensor-th-plus.js.map +1 -0
- package/dist/devices/wo-sensor-th-pro-co2.d.ts +8 -0
- package/dist/devices/wo-sensor-th-pro-co2.d.ts.map +1 -0
- package/dist/devices/wo-sensor-th-pro-co2.js +12 -0
- package/dist/devices/wo-sensor-th-pro-co2.js.map +1 -0
- package/dist/devices/wo-sensor-th-pro.d.ts +8 -0
- package/dist/devices/wo-sensor-th-pro.d.ts.map +1 -0
- package/dist/devices/wo-sensor-th-pro.js +12 -0
- package/dist/devices/wo-sensor-th-pro.js.map +1 -0
- package/dist/devices/wo-sensor-th.d.ts +12 -0
- package/dist/devices/wo-sensor-th.d.ts.map +1 -0
- package/dist/devices/wo-sensor-th.js +49 -0
- package/dist/devices/wo-sensor-th.js.map +1 -0
- package/dist/devices/wo-strip.d.ts +8 -0
- package/dist/devices/wo-strip.d.ts.map +1 -0
- package/dist/devices/wo-strip.js +12 -0
- package/dist/devices/wo-strip.js.map +1 -0
- package/dist/errors.d.ts +63 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +103 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +10 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -10
- package/dist/index.js.map +1 -1
- package/dist/settings.d.ts +126 -47
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +214 -64
- package/dist/settings.js.map +1 -1
- package/dist/switchbot.d.ts +87 -0
- package/dist/switchbot.d.ts.map +1 -0
- package/dist/switchbot.js +422 -0
- package/dist/switchbot.js.map +1 -0
- package/dist/types/api.d.ts +187 -0
- package/dist/types/api.d.ts.map +1 -0
- package/dist/types/api.js +6 -0
- package/dist/types/api.js.map +1 -0
- package/dist/types/ble.d.ts +246 -348
- package/dist/types/ble.d.ts.map +1 -1
- package/dist/types/ble.js +94 -1
- package/dist/types/ble.js.map +1 -1
- package/dist/types/device.d.ts +209 -0
- package/dist/types/device.d.ts.map +1 -0
- package/dist/types/device.js +6 -0
- package/dist/types/device.js.map +1 -0
- package/dist/types/index.d.ts +115 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +19 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/index.d.ts +97 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +206 -0
- package/dist/utils/index.js.map +1 -0
- package/docs/assets/hierarchy.js +1 -1
- package/docs/assets/highlight.css +20 -6
- package/docs/assets/icons.js +1 -1
- package/docs/assets/icons.svg +1 -1
- package/docs/assets/main.js +2 -2
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/assets/style.css +3 -3
- package/docs/classes/APIError.html +6 -0
- package/docs/classes/APINotAvailableError.html +4 -0
- package/docs/classes/BLEConnection.html +17 -0
- package/docs/classes/BLENotAvailableError.html +4 -0
- package/docs/classes/BLEScanner.html +15 -0
- package/docs/classes/CommandFailedError.html +6 -0
- package/docs/classes/ConnectionTimeoutError.html +5 -0
- package/docs/classes/DeviceManager.html +25 -0
- package/docs/classes/DeviceNotFoundError.html +4 -0
- package/docs/classes/DiscoveryError.html +5 -0
- package/docs/classes/OpenAPIClient.html +66 -0
- package/docs/classes/SwitchBot.html +22 -0
- package/docs/classes/SwitchBotDevice.html +28 -0
- package/docs/classes/SwitchBotError.html +4 -0
- package/docs/classes/ValidationError.html +5 -0
- package/docs/classes/WoAirPurifier.html +32 -80
- package/docs/classes/WoAirPurifierTable.html +36 -83
- package/docs/classes/WoBlindTilt.html +34 -73
- package/docs/classes/WoBulb.html +33 -85
- package/docs/classes/WoCeilingLight.html +38 -107
- package/docs/classes/WoContact.html +27 -52
- package/docs/classes/WoCurtain.html +32 -69
- package/docs/classes/WoHand.html +30 -59
- package/docs/classes/WoHub2.html +27 -52
- package/docs/classes/WoHub3.html +28 -52
- package/docs/classes/WoHumi.html +33 -65
- package/docs/classes/WoHumi2.html +36 -67
- package/docs/classes/WoIOSensorTH.html +28 -53
- package/docs/classes/WoKeypad.html +28 -52
- package/docs/classes/WoLeak.html +27 -53
- package/docs/classes/WoPlugMiniJP.html +34 -78
- package/docs/classes/WoPlugMiniUS.html +30 -75
- package/docs/classes/WoPresence.html +27 -60
- package/docs/classes/WoRelaySwitch1.html +31 -55
- package/docs/classes/WoRelaySwitch1PM.html +34 -57
- package/docs/classes/WoRemote.html +28 -52
- package/docs/classes/WoSensorTH.html +27 -46
- package/docs/classes/WoSensorTHPlus.html +28 -46
- package/docs/classes/WoSensorTHPro.html +28 -46
- package/docs/classes/WoSensorTHProCO2.html +28 -46
- package/docs/classes/WoSmartLock.html +29 -111
- package/docs/classes/WoSmartLockPro.html +31 -111
- package/docs/classes/WoStrip.html +38 -94
- package/docs/enums/LogLevel.html +4 -7
- package/docs/enums/SwitchBotBLEModel.html +11 -6
- package/docs/enums/SwitchBotBLEModelName.html +13 -6
- package/docs/functions/updateBaseURL.html +3 -3
- package/docs/hierarchy.html +1 -1
- package/docs/index.html +40 -6
- package/docs/interfaces/APICommandRequest.html +5 -0
- package/docs/interfaces/APICommandResponse.html +5 -0
- package/docs/interfaces/APIDevice.html +18 -0
- package/docs/interfaces/APIDeviceStatus.html +36 -0
- package/docs/interfaces/APIErrorResponse.html +5 -0
- package/docs/interfaces/APIResponse.html +5 -0
- package/docs/interfaces/AirPurifierCommands.html +5 -0
- package/docs/interfaces/AirPurifierServiceData.html +14 -0
- package/docs/interfaces/AirPurifierStatus.html +17 -0
- package/docs/interfaces/BLEAdvertisement.html +6 -0
- package/docs/interfaces/BLEScanOptions.html +10 -0
- package/docs/interfaces/BLEServiceData.html +10 -0
- package/docs/interfaces/BlindTiltCommands.html +7 -0
- package/docs/interfaces/BlindTiltServiceData.html +14 -0
- package/docs/interfaces/BlindTiltStatus.html +15 -0
- package/docs/interfaces/BotCommands.html +4 -0
- package/docs/interfaces/BotServiceData.html +12 -0
- package/docs/interfaces/BotStatus.html +14 -0
- package/docs/interfaces/BulbCommands.html +6 -0
- package/docs/interfaces/BulbServiceData.html +19 -0
- package/docs/interfaces/BulbStatus.html +16 -0
- package/docs/interfaces/CeilingLightCommands.html +6 -0
- package/docs/interfaces/CeilingLightServiceData.html +19 -0
- package/docs/interfaces/CeilingLightStatus.html +16 -0
- package/docs/interfaces/CommandResult.html +12 -0
- package/docs/interfaces/ContactServiceData.html +13 -0
- package/docs/interfaces/ContactStatus.html +15 -0
- package/docs/interfaces/CurtainCommands.html +5 -0
- package/docs/interfaces/CurtainServiceData.html +14 -0
- package/docs/interfaces/CurtainStatus.html +17 -0
- package/docs/interfaces/DeviceInfo.html +26 -0
- package/docs/interfaces/DeviceListResponse.html +4 -0
- package/docs/interfaces/DeviceStatus.html +12 -0
- package/docs/interfaces/DiscoveryOptions.html +14 -0
- package/docs/interfaces/HubServiceData.html +14 -0
- package/docs/interfaces/HubStatus.html +15 -0
- package/docs/interfaces/HumidifierCommands.html +5 -0
- package/docs/interfaces/HumidifierServiceData.html +14 -0
- package/docs/interfaces/HumidifierStatus.html +18 -0
- package/docs/interfaces/KeypadStatus.html +13 -0
- package/docs/interfaces/LeakServiceData.html +11 -0
- package/docs/interfaces/LeakStatus.html +13 -0
- package/docs/interfaces/LockCommands.html +3 -0
- package/docs/interfaces/LockServiceData.html +15 -0
- package/docs/interfaces/LockStatus.html +15 -0
- package/docs/interfaces/MeterServiceData.html +13 -0
- package/docs/interfaces/MeterStatus.html +15 -0
- package/docs/interfaces/MotionServiceData.html +13 -0
- package/docs/interfaces/MotionStatus.html +14 -0
- package/docs/interfaces/PlugCommands.html +4 -0
- package/docs/interfaces/PlugServiceData.html +17 -0
- package/docs/interfaces/PlugStatus.html +16 -0
- package/docs/interfaces/PresenceServiceData.html +12 -0
- package/docs/interfaces/PresenceStatus.html +14 -0
- package/docs/interfaces/RelaySwitchCommands.html +4 -0
- package/docs/interfaces/RelaySwitchServiceData.html +14 -0
- package/docs/interfaces/RelaySwitchStatus.html +16 -0
- package/docs/interfaces/RemoteStatus.html +12 -0
- package/docs/interfaces/SceneListResponse.html +3 -0
- package/docs/interfaces/StripCommands.html +6 -0
- package/docs/interfaces/StripServiceData.html +19 -0
- package/docs/interfaces/StripStatus.html +16 -0
- package/docs/interfaces/SwitchBotConfig.html +18 -0
- package/docs/interfaces/WebhookConfig.html +4 -0
- package/docs/interfaces/WebhookDetails.html +7 -0
- package/docs/interfaces/WebhookQueryResponse.html +5 -0
- package/docs/interfaces/WebhookSetupResponse.html +5 -0
- package/docs/modules.html +1 -1
- package/docs/types/ConnectionType.html +2 -0
- package/docs/types/PhysicalDeviceType.html +2 -0
- package/docs/types/VirtualDeviceType.html +2 -0
- package/docs/variables/urls.html +1 -1
- package/package.json +12 -21
- package/.github/scripts/npm-version-script-esm-auto.js +0 -207
- package/dist/device.d.ts +0 -1626
- package/dist/device.d.ts.map +0 -1
- package/dist/device.js +0 -3602
- package/dist/device.js.map +0 -1
- package/dist/device.test.d.ts +0 -2
- package/dist/device.test.d.ts.map +0 -1
- package/dist/device.test.js +0 -336
- package/dist/device.test.js.map +0 -1
- package/dist/index.test.d.ts +0 -2
- package/dist/index.test.d.ts.map +0 -1
- package/dist/index.test.js +0 -14
- package/dist/index.test.js.map +0 -1
- package/dist/parameter-checker.d.ts +0 -91
- package/dist/parameter-checker.d.ts.map +0 -1
- package/dist/parameter-checker.js +0 -262
- package/dist/parameter-checker.js.map +0 -1
- package/dist/parameter-checker.test.d.ts +0 -2
- package/dist/parameter-checker.test.d.ts.map +0 -1
- package/dist/parameter-checker.test.js +0 -56
- package/dist/parameter-checker.test.js.map +0 -1
- package/dist/settings.test.d.ts +0 -2
- package/dist/settings.test.d.ts.map +0 -1
- package/dist/settings.test.js +0 -61
- package/dist/settings.test.js.map +0 -1
- package/dist/switchbot-ble.d.ts +0 -89
- package/dist/switchbot-ble.d.ts.map +0 -1
- package/dist/switchbot-ble.js +0 -320
- package/dist/switchbot-ble.js.map +0 -1
- package/dist/switchbot-ble.test.d.ts +0 -2
- package/dist/switchbot-ble.test.d.ts.map +0 -1
- package/dist/switchbot-ble.test.js +0 -32
- package/dist/switchbot-ble.test.js.map +0 -1
- package/dist/switchbot-openapi.d.ts +0 -139
- package/dist/switchbot-openapi.d.ts.map +0 -1
- package/dist/switchbot-openapi.js +0 -375
- package/dist/switchbot-openapi.js.map +0 -1
- package/dist/switchbot-openapi.test.d.ts +0 -2
- package/dist/switchbot-openapi.test.d.ts.map +0 -1
- package/dist/switchbot-openapi.test.js +0 -36
- package/dist/switchbot-openapi.test.js.map +0 -1
- package/dist/types/ble-guards.d.ts +0 -12
- package/dist/types/ble-guards.d.ts.map +0 -1
- package/dist/types/ble-guards.js +0 -10
- package/dist/types/ble-guards.js.map +0 -1
- package/dist/types/ble-guards.test.d.ts +0 -2
- package/dist/types/ble-guards.test.d.ts.map +0 -1
- package/dist/types/ble-guards.test.js +0 -62
- package/dist/types/ble-guards.test.js.map +0 -1
- package/dist/types/openapi.d.ts +0 -638
- package/dist/types/openapi.d.ts.map +0 -1
- package/dist/types/openapi.js +0 -3
- package/dist/types/openapi.js.map +0 -1
- package/docs/classes/Advertising.html +0 -21
- package/docs/classes/ErrorUtils.html +0 -25
- package/docs/classes/ParameterChecker.html +0 -69
- package/docs/classes/SwitchBotBLE.html +0 -39
- package/docs/classes/SwitchBotOpenAPI.html +0 -57
- package/docs/classes/SwitchbotDevice.html +0 -47
- package/docs/classes/ValidationUtils.html +0 -51
- package/docs/classes/WoPlugMiniEU.html +0 -84
- package/docs/classes/WoSmartLockUltra.html +0 -113
- package/docs/enums/SwitchBotBLEModelFriendlyName.html +0 -39
- package/docs/enums/SwitchBotModel.html +0 -53
- package/docs/interfaces/AdvertisementData.html +0 -3
- package/docs/interfaces/Chars.html +0 -4
- package/docs/interfaces/ColorLightServiceDataBase.html +0 -17
- package/docs/interfaces/ErrorObject.html +0 -3
- package/docs/interfaces/LockBaseServiceData.html +0 -15
- package/docs/interfaces/NobleTypes.html +0 -3
- package/docs/interfaces/Params.html +0 -6
- package/docs/interfaces/PlugMiniServiceDataBase.html +0 -12
- package/docs/interfaces/Rule.html +0 -9
- package/docs/interfaces/ServiceData.html +0 -2
- package/docs/interfaces/SwitchBotBLEDevice.html +0 -28
- package/docs/interfaces/SwitchBotScanner.html +0 -6
- package/docs/interfaces/TemperatureServiceDataBase.html +0 -10
- package/docs/interfaces/WebhookDetail.html +0 -6
- package/docs/interfaces/ad.html +0 -5
- package/docs/interfaces/body.html +0 -3
- package/docs/interfaces/bodyChange.html +0 -4
- package/docs/interfaces/deleteWebhookResponse.html +0 -4
- package/docs/interfaces/device.html +0 -7
- package/docs/interfaces/deviceList.html +0 -2
- package/docs/interfaces/deviceStatus.html +0 -7
- package/docs/interfaces/deviceStatusRequest.html +0 -4
- package/docs/interfaces/deviceWebhook.html +0 -4
- package/docs/interfaces/deviceWebhookContext.html +0 -4
- package/docs/interfaces/devices.html +0 -4
- package/docs/interfaces/infraredRemoteList.html +0 -2
- package/docs/interfaces/irdevice.html +0 -5
- package/docs/interfaces/pushRequest.html +0 -5
- package/docs/interfaces/pushResponse.html +0 -5
- package/docs/interfaces/pushResponseBody.html +0 -3
- package/docs/interfaces/queryWebhookResponse.html +0 -4
- package/docs/interfaces/setupWebhookResponse.html +0 -4
- package/docs/interfaces/updateWebhookResponse.html +0 -4
- package/docs/interfaces/webhookRequest.html +0 -4
- package/docs/types/BLEDeviceServiceData.html +0 -1
- package/docs/types/IndoorCam.html +0 -1
- package/docs/types/MacAddress.html +0 -1
- package/docs/types/airPurifier.html +0 -1
- package/docs/types/airPurifierPM25WebhookContext.html +0 -1
- package/docs/types/airPurifierServiceData.html +0 -1
- package/docs/types/airPurifierStatus.html +0 -1
- package/docs/types/airPurifierTable.html +0 -1
- package/docs/types/airPurifierTablePM25WebhookContext.html +0 -1
- package/docs/types/airPurifierTableServiceData.html +0 -1
- package/docs/types/airPurifierTableStatus.html +0 -1
- package/docs/types/airPurifierTableVOC.html +0 -1
- package/docs/types/airPurifierTableVOCStatus.html +0 -1
- package/docs/types/airPurifierTableVOCWebhookContext.html +0 -1
- package/docs/types/airPurifierTableWebhookContext.html +0 -1
- package/docs/types/airPurifierVOC.html +0 -1
- package/docs/types/airPurifierVOCStatus.html +0 -1
- package/docs/types/airPurifierVOCWebhookContext.html +0 -1
- package/docs/types/airPurifierWebhookContext.html +0 -1
- package/docs/types/batteryCirculatorFan.html +0 -1
- package/docs/types/batteryCirculatorFanServiceData.html +0 -1
- package/docs/types/batteryCirculatorFanStatus.html +0 -1
- package/docs/types/batteryCirculatorFanWebhookContext.html +0 -1
- package/docs/types/blindTilt.html +0 -1
- package/docs/types/blindTiltServiceData.html +0 -1
- package/docs/types/blindTiltStatus.html +0 -1
- package/docs/types/blindTiltWebhookContext.html +0 -1
- package/docs/types/bot.html +0 -1
- package/docs/types/botServiceData.html +0 -1
- package/docs/types/botStatus.html +0 -1
- package/docs/types/botWebhookContext.html +0 -1
- package/docs/types/ceilingLight.html +0 -1
- package/docs/types/ceilingLightPro.html +0 -1
- package/docs/types/ceilingLightProServiceData.html +0 -1
- package/docs/types/ceilingLightProStatus.html +0 -1
- package/docs/types/ceilingLightProWebhookContext.html +0 -1
- package/docs/types/ceilingLightServiceData.html +0 -1
- package/docs/types/ceilingLightStatus.html +0 -1
- package/docs/types/ceilingLightWebhookContext.html +0 -1
- package/docs/types/circulatorFanStatus.html +0 -1
- package/docs/types/circulatorFanWebhookContext.html +0 -1
- package/docs/types/colorBulb.html +0 -1
- package/docs/types/colorBulbServiceData.html +0 -1
- package/docs/types/colorBulbStatus.html +0 -1
- package/docs/types/colorBulbWebhookContext.html +0 -1
- package/docs/types/commandType.html +0 -2
- package/docs/types/contactSensor.html +0 -1
- package/docs/types/contactSensorServiceData.html +0 -1
- package/docs/types/contactSensorStatus.html +0 -1
- package/docs/types/contactSensorWebhookContext.html +0 -1
- package/docs/types/curtain.html +0 -1
- package/docs/types/curtain3.html +0 -1
- package/docs/types/curtain3ServiceData.html +0 -1
- package/docs/types/curtain3WebhookContext.html +0 -1
- package/docs/types/curtainServiceData.html +0 -1
- package/docs/types/curtainStatus.html +0 -1
- package/docs/types/curtainWebhookContext.html +0 -1
- package/docs/types/floorCleaningRobotS10.html +0 -1
- package/docs/types/floorCleaningRobotS10Status.html +0 -1
- package/docs/types/floorCleaningRobotS10WebhookContext.html +0 -1
- package/docs/types/hub2.html +0 -1
- package/docs/types/hub2ServiceData.html +0 -1
- package/docs/types/hub2Status.html +0 -1
- package/docs/types/hub2WebhookContext.html +0 -1
- package/docs/types/hub3ServiceData.html +0 -1
- package/docs/types/humidifier.html +0 -1
- package/docs/types/humidifier2ServiceData.html +0 -1
- package/docs/types/humidifier2Status.html +0 -1
- package/docs/types/humidifier2WebhookContext.html +0 -1
- package/docs/types/humidifierServiceData.html +0 -1
- package/docs/types/humidifierStatus.html +0 -1
- package/docs/types/humidifierWebhookContext.html +0 -1
- package/docs/types/indoorCameraWebhookContext.html +0 -1
- package/docs/types/keypad.html +0 -1
- package/docs/types/keypadDetectorServiceData.html +0 -1
- package/docs/types/keypadTouch.html +0 -1
- package/docs/types/keypadTouchWebhookContext.html +0 -1
- package/docs/types/keypadWebhookContext.html +0 -1
- package/docs/types/lock.html +0 -1
- package/docs/types/lockPro.html +0 -1
- package/docs/types/lockProServiceData.html +0 -1
- package/docs/types/lockProStatus.html +0 -1
- package/docs/types/lockProWebhookContext.html +0 -1
- package/docs/types/lockServiceData.html +0 -1
- package/docs/types/lockStatus.html +0 -1
- package/docs/types/lockWebhookContext.html +0 -1
- package/docs/types/meter.html +0 -1
- package/docs/types/meterPlus.html +0 -1
- package/docs/types/meterPlusServiceData.html +0 -1
- package/docs/types/meterPlusStatus.html +0 -1
- package/docs/types/meterPlusWebhookContext.html +0 -1
- package/docs/types/meterPro.html +0 -1
- package/docs/types/meterProCO2ServiceData.html +0 -1
- package/docs/types/meterProCO2Status.html +0 -1
- package/docs/types/meterProCO2WebhookContext.html +0 -1
- package/docs/types/meterProServiceData.html +0 -1
- package/docs/types/meterProStatus.html +0 -1
- package/docs/types/meterProWebhookContext.html +0 -1
- package/docs/types/meterServiceData.html +0 -1
- package/docs/types/meterStatus.html +0 -1
- package/docs/types/meterWebhookContext.html +0 -1
- package/docs/types/motionSensor.html +0 -1
- package/docs/types/motionSensorServiceData.html +0 -1
- package/docs/types/motionSensorStatus.html +0 -1
- package/docs/types/motionSensorWebhookContext.html +0 -1
- package/docs/types/onadvertisement.html +0 -1
- package/docs/types/ondiscover.html +0 -1
- package/docs/types/outdoorMeter.html +0 -1
- package/docs/types/outdoorMeterServiceData.html +0 -1
- package/docs/types/outdoorMeterStatus.html +0 -1
- package/docs/types/outdoorMeterWebhookContext.html +0 -1
- package/docs/types/panTiltCamWebhookContext.html +0 -1
- package/docs/types/pantiltCam.html +0 -1
- package/docs/types/pantiltCam2k.html +0 -1
- package/docs/types/plug.html +0 -1
- package/docs/types/plugMini.html +0 -1
- package/docs/types/plugMiniEUServiceData.html +0 -1
- package/docs/types/plugMiniEUWebhookContext.html +0 -1
- package/docs/types/plugMiniJPServiceData.html +0 -1
- package/docs/types/plugMiniJPWebhookContext.html +0 -1
- package/docs/types/plugMiniStatus.html +0 -1
- package/docs/types/plugMiniUSServiceData.html +0 -1
- package/docs/types/plugMiniUSWebhookContext.html +0 -1
- package/docs/types/plugStatus.html +0 -1
- package/docs/types/plugWebhookContext.html +0 -1
- package/docs/types/presenceSensor.html +0 -1
- package/docs/types/presenceSensorServiceData.html +0 -1
- package/docs/types/presenceSensorStatus.html +0 -1
- package/docs/types/presenceSensorWebhookContext.html +0 -1
- package/docs/types/relaySwitch1Context.html +0 -1
- package/docs/types/relaySwitch1PMContext.html +0 -1
- package/docs/types/relaySwitch1PMServiceData.html +0 -1
- package/docs/types/relaySwitch1PMStatus.html +0 -1
- package/docs/types/relaySwitch1ServiceData.html +0 -1
- package/docs/types/relaySwitch1Status.html +0 -1
- package/docs/types/remote.html +0 -1
- package/docs/types/remoteServiceData.html +0 -1
- package/docs/types/robotVacuumCleanerS1.html +0 -1
- package/docs/types/robotVacuumCleanerS1Plus.html +0 -1
- package/docs/types/robotVacuumCleanerS1PlusStatus.html +0 -1
- package/docs/types/robotVacuumCleanerS1PlusWebhookContext.html +0 -1
- package/docs/types/robotVacuumCleanerS1Status.html +0 -1
- package/docs/types/robotVacuumCleanerS1WebhookContext.html +0 -1
- package/docs/types/robotVacuumCleanerServiceData.html +0 -1
- package/docs/types/stripLight.html +0 -1
- package/docs/types/stripLightServiceData.html +0 -1
- package/docs/types/stripLightStatus.html +0 -1
- package/docs/types/stripLightWebhookContext.html +0 -1
- package/docs/types/waterLeakDetector.html +0 -1
- package/docs/types/waterLeakDetectorServiceData.html +0 -1
- package/docs/types/waterLeakDetectorStatus.html +0 -1
- package/docs/types/waterLeakDetectorWebhookContext.html +0 -1
- package/docs/variables/parameterChecker.html +0 -1
- package/eslint.config.js +0 -48
- package/typedoc.json +0 -17
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/* Copyright(C) 2024-2026, donavanbecker (https://github.com/donavanbecker). All rights reserved.
|
|
2
|
+
*
|
|
3
|
+
* devices/wo-blind-tilt.ts: SwitchBot v4.0.0 - Blind Tilt Device
|
|
4
|
+
*/
|
|
5
|
+
import { DEVICE_COMMANDS } from '../settings.js';
|
|
6
|
+
import { clamp } from '../utils/index.js';
|
|
7
|
+
import { SwitchBotDevice } from './base.js';
|
|
8
|
+
/**
|
|
9
|
+
* Blind Tilt Device
|
|
10
|
+
*/
|
|
11
|
+
export class WoBlindTilt extends SwitchBotDevice {
|
|
12
|
+
/**
|
|
13
|
+
* Open blind (position 50%)
|
|
14
|
+
*/
|
|
15
|
+
async open() {
|
|
16
|
+
const result = await this.sendCommand(DEVICE_COMMANDS.BLIND_TILT.OPEN, 'turnOn');
|
|
17
|
+
return result.success;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Close blind up (position 100%)
|
|
21
|
+
*/
|
|
22
|
+
async closeUp() {
|
|
23
|
+
const result = await this.sendCommand(DEVICE_COMMANDS.BLIND_TILT.CLOSE_UP, 'setPosition', '0,ff,100');
|
|
24
|
+
return result.success;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Close blind down (position 0%)
|
|
28
|
+
*/
|
|
29
|
+
async closeDown() {
|
|
30
|
+
const result = await this.sendCommand(DEVICE_COMMANDS.BLIND_TILT.CLOSE_DOWN, 'setPosition', '0,ff,0');
|
|
31
|
+
return result.success;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Close (default to close down)
|
|
35
|
+
*/
|
|
36
|
+
async close() {
|
|
37
|
+
return this.closeDown();
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Pause blind movement
|
|
41
|
+
*/
|
|
42
|
+
async pause() {
|
|
43
|
+
const result = await this.sendCommand(DEVICE_COMMANDS.BLIND_TILT.PAUSE, 'pause');
|
|
44
|
+
return result.success;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Set blind position (0-100%)
|
|
48
|
+
*/
|
|
49
|
+
async setPosition(position) {
|
|
50
|
+
const clampedPosition = clamp(position, 0, 100);
|
|
51
|
+
// Calculate tilt angle for BLE (0-100 maps to 0-180 degrees)
|
|
52
|
+
const angle = Math.round((clampedPosition / 100) * 180);
|
|
53
|
+
const bleCommand = [0x57, 0x0F, 0x45, 0x01, 0x05, 0xFF, angle];
|
|
54
|
+
const result = await this.sendCommand(bleCommand, 'setPosition', `0,ff,${clampedPosition}`);
|
|
55
|
+
return result.success;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Get device status
|
|
59
|
+
*/
|
|
60
|
+
async getStatus() {
|
|
61
|
+
try {
|
|
62
|
+
// Try API first if available
|
|
63
|
+
if (this.hasAPI()) {
|
|
64
|
+
const apiStatus = await this.getAPIStatus();
|
|
65
|
+
return {
|
|
66
|
+
deviceId: this.info.id,
|
|
67
|
+
connectionType: 'api',
|
|
68
|
+
position: apiStatus.slidePosition || 0,
|
|
69
|
+
moving: apiStatus.moving,
|
|
70
|
+
battery: apiStatus.battery,
|
|
71
|
+
version: apiStatus.version,
|
|
72
|
+
updatedAt: new Date(),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
// Fallback to BLE
|
|
76
|
+
if (this.hasBLE()) {
|
|
77
|
+
const bleData = await this.getBLEStatus();
|
|
78
|
+
return {
|
|
79
|
+
deviceId: this.info.id,
|
|
80
|
+
connectionType: 'ble',
|
|
81
|
+
position: bleData.position || 0,
|
|
82
|
+
moving: bleData.inMotion,
|
|
83
|
+
battery: bleData.battery,
|
|
84
|
+
updatedAt: new Date(),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
throw new Error('No connection method available');
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
this.logger.error('Failed to get status', error);
|
|
91
|
+
throw error;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=wo-blind-tilt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wo-blind-tilt.js","sourceRoot":"","sources":["../../src/devices/wo-blind-tilt.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAE3C;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,eAAe;IAC9C;;OAEG;IACH,KAAK,CAAC,IAAI;QACR,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CACnC,eAAe,CAAC,UAAU,CAAC,IAAI,EAC/B,QAAQ,CACT,CAAA;QACD,OAAO,MAAM,CAAC,OAAO,CAAA;IACvB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO;QACX,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CACnC,eAAe,CAAC,UAAU,CAAC,QAAQ,EACnC,aAAa,EACb,UAAU,CACX,CAAA;QACD,OAAO,MAAM,CAAC,OAAO,CAAA;IACvB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,SA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oBACrB,QAAQ,EAAE,SAAS,CAAC,aAAa,IAAI,CAAC;oBACtC,MAAM,EAAE,SAAS,CAAC,MAAM;oBACxB,OAAO,EAAE,SAAS,CAAC,OAAO;oBAC1B,OAAO,EAAE,SAAS,CAAC,OAAO;oBAC1B,SAAS,EAAE,IAAI,IAAI,EAAE;iBACtB,CAAA;YACH,CAAC;YAED,kBAAkB;YAClB,IAAI,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;gBAClB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,YAAY,EAAE,CAAA;gBACzC,OAAO;oBACL,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE;oBACtB,cAAc,EAAE,KAAK;oBACrB,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,CAAC;oBAC/B,MAAM,EAAE,OAAO,CAAC,QAAQ;oBACxB,OAAO,EAAE,OAAO,CAAC,OAAO;oBACxB,SAAS,EAAE,IAAI,IAAI,EAAE;iBACtB,CAAA;YACH,CAAC;YAED,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;QACnD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAA;YAChD,MAAM,KAAK,CAAA;QACb,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { BulbCommands, BulbStatus } from '../types/device.js';
|
|
2
|
+
import { SwitchBotDevice } from './base.js';
|
|
3
|
+
/**
|
|
4
|
+
* Color Bulb Device
|
|
5
|
+
*/
|
|
6
|
+
export declare class WoBulb extends SwitchBotDevice implements BulbCommands {
|
|
7
|
+
/**
|
|
8
|
+
* Turn on
|
|
9
|
+
*/
|
|
10
|
+
turnOn(): Promise<boolean>;
|
|
11
|
+
/**
|
|
12
|
+
* Turn off
|
|
13
|
+
*/
|
|
14
|
+
turnOff(): Promise<boolean>;
|
|
15
|
+
/**
|
|
16
|
+
* Set brightness (0-100)
|
|
17
|
+
*/
|
|
18
|
+
setBrightness(brightness: number): Promise<boolean>;
|
|
19
|
+
/**
|
|
20
|
+
* Set color temperature (2700-6500K)
|
|
21
|
+
*/
|
|
22
|
+
setColorTemperature(temperature: number): Promise<boolean>;
|
|
23
|
+
/**
|
|
24
|
+
* Set RGB color
|
|
25
|
+
*/
|
|
26
|
+
setColor(red: number, green: number, blue: number): Promise<boolean>;
|
|
27
|
+
/**
|
|
28
|
+
* Get device status
|
|
29
|
+
*/
|
|
30
|
+
getStatus(): Promise<BulbStatus>;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=wo-bulb.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wo-bulb.d.ts","sourceRoot":"","sources":["../../src/devices/wo-bulb.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAIlE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAE3C;;GAEG;AACH,qBAAa,MAAO,SAAQ,eAAgB,YAAW,YAAY;IACjE;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC;IAQhC;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;IAQjC;;OAEG;IACG,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAazD;;OAEG;IACG,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAehE;;OAEG;IACG,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAe1E;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,UAAU,CAAC;CAmDvC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/* Copyright(C) 2024-2026, donavanbecker (https://github.com/donavanbecker). All rights reserved.
|
|
2
|
+
*
|
|
3
|
+
* devices/wo-bulb.ts: SwitchBot v4.0.0 - Color Bulb
|
|
4
|
+
*/
|
|
5
|
+
import { DEVICE_COMMANDS } from '../settings.js';
|
|
6
|
+
import { clamp } from '../utils/index.js';
|
|
7
|
+
import { SwitchBotDevice } from './base.js';
|
|
8
|
+
/**
|
|
9
|
+
* Color Bulb Device
|
|
10
|
+
*/
|
|
11
|
+
export class WoBulb extends SwitchBotDevice {
|
|
12
|
+
/**
|
|
13
|
+
* Turn on
|
|
14
|
+
*/
|
|
15
|
+
async turnOn() {
|
|
16
|
+
const result = await this.sendCommand([...DEVICE_COMMANDS.BULB.BASE, ...DEVICE_COMMANDS.BULB.TURN_ON], 'turnOn');
|
|
17
|
+
return result.success;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Turn off
|
|
21
|
+
*/
|
|
22
|
+
async turnOff() {
|
|
23
|
+
const result = await this.sendCommand([...DEVICE_COMMANDS.BULB.BASE, ...DEVICE_COMMANDS.BULB.TURN_OFF], 'turnOff');
|
|
24
|
+
return result.success;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Set brightness (0-100)
|
|
28
|
+
*/
|
|
29
|
+
async setBrightness(brightness) {
|
|
30
|
+
const clampedBrightness = clamp(brightness, 0, 100);
|
|
31
|
+
const bleCommand = [...DEVICE_COMMANDS.BULB.BASE, ...DEVICE_COMMANDS.BULB.SET_BRIGHTNESS, clampedBrightness];
|
|
32
|
+
const result = await this.sendCommand(bleCommand, 'setBrightness', clampedBrightness);
|
|
33
|
+
return result.success;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Set color temperature (2700-6500K)
|
|
37
|
+
*/
|
|
38
|
+
async setColorTemperature(temperature) {
|
|
39
|
+
const clampedTemp = clamp(temperature, 2700, 6500);
|
|
40
|
+
// Convert to bytes for BLE
|
|
41
|
+
const tempBytes = [(clampedTemp >> 8) & 0xFF, clampedTemp & 0xFF];
|
|
42
|
+
const bleCommand = [...DEVICE_COMMANDS.BULB.BASE, ...DEVICE_COMMANDS.BULB.SET_COLOR_TEMP, ...tempBytes];
|
|
43
|
+
const result = await this.sendCommand(bleCommand, 'setColorTemperature', clampedTemp);
|
|
44
|
+
return result.success;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Set RGB color
|
|
48
|
+
*/
|
|
49
|
+
async setColor(red, green, blue) {
|
|
50
|
+
const r = clamp(red, 0, 255);
|
|
51
|
+
const g = clamp(green, 0, 255);
|
|
52
|
+
const b = clamp(blue, 0, 255);
|
|
53
|
+
const bleCommand = [...DEVICE_COMMANDS.BULB.BASE, ...DEVICE_COMMANDS.BULB.SET_RGB, r, g, b];
|
|
54
|
+
const result = await this.sendCommand(bleCommand, 'setColor', `${r}:${g}:${b}`);
|
|
55
|
+
return result.success;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Get device status
|
|
59
|
+
*/
|
|
60
|
+
async getStatus() {
|
|
61
|
+
try {
|
|
62
|
+
// Try API first if available
|
|
63
|
+
if (this.hasAPI()) {
|
|
64
|
+
const apiStatus = await this.getAPIStatus();
|
|
65
|
+
// Parse color if available (format: "255:255:255")
|
|
66
|
+
let color;
|
|
67
|
+
if (apiStatus.color) {
|
|
68
|
+
const [r, g, b] = apiStatus.color.split(':').map(Number);
|
|
69
|
+
color = { r, g, b };
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
deviceId: this.info.id,
|
|
73
|
+
connectionType: 'api',
|
|
74
|
+
power: apiStatus.power || 'off',
|
|
75
|
+
brightness: apiStatus.brightness,
|
|
76
|
+
colorTemperature: apiStatus.colorTemperature,
|
|
77
|
+
color,
|
|
78
|
+
version: apiStatus.version,
|
|
79
|
+
updatedAt: new Date(),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
// Fallback to BLE
|
|
83
|
+
if (this.hasBLE()) {
|
|
84
|
+
const bleData = await this.getBLEStatus();
|
|
85
|
+
return {
|
|
86
|
+
deviceId: this.info.id,
|
|
87
|
+
connectionType: 'ble',
|
|
88
|
+
power: bleData.state ? 'on' : 'off',
|
|
89
|
+
brightness: bleData.brightness,
|
|
90
|
+
colorTemperature: bleData.colorTemperature,
|
|
91
|
+
color: bleData.red !== undefined
|
|
92
|
+
? {
|
|
93
|
+
r: bleData.red,
|
|
94
|
+
g: bleData.green,
|
|
95
|
+
b: bleData.blue,
|
|
96
|
+
}
|
|
97
|
+
: undefined,
|
|
98
|
+
updatedAt: new Date(),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
throw new Error('No connection method available');
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
this.logger.error('Failed to get status', error);
|
|
105
|
+
throw error;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=wo-bulb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wo-bulb.js","sourceRoot":"","sources":["../../src/devices/wo-bulb.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAE3C;;GAEG;AACH,MAAM,OAAO,MAAO,SAAQ,eAAe;IACzC;;OAEG;IACH,KAAK,CAAC,MAAM;QACV,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CACnC,CAAC,GAAG,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,EAC/D,QAAQ,CACT,CAAA;QACD,OAAO,MAAM,CAAC,OAAO,CAAA;IACvB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO;QACX,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,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|
1
|
+
/* Copyright(C) 2024-2026, donavanbecker (https://github.com/donavanbecker). All rights reserved.
|
|
2
|
+
*
|
|
3
|
+
* devices/wo-ceiling-light.ts: SwitchBot v4.0.0 - Ceiling Light
|
|
4
|
+
*/
|
|
5
|
+
import { WoBulb } from './wo-bulb.js';
|
|
6
|
+
/**
|
|
7
|
+
* Ceiling Light Device
|
|
8
|
+
* Uses same logic as Color Bulb
|
|
9
|
+
*/
|
|
10
|
+
export class WoCeilingLight extends WoBulb {
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=wo-ceiling-light.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wo-ceiling-light.js","sourceRoot":"","sources":["../../src/devices/wo-ceiling-light.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAErC;;;GAGG;AACH,MAAM,OAAO,cAAe,SAAQ,MAAM;CAAG"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ContactStatus } from '../types/device.js';
|
|
2
|
+
import { SwitchBotDevice } from './base.js';
|
|
3
|
+
/**
|
|
4
|
+
* Contact Sensor (Door/Window Sensor)
|
|
5
|
+
*/
|
|
6
|
+
export declare class WoContact extends SwitchBotDevice {
|
|
7
|
+
/**
|
|
8
|
+
* Get device status
|
|
9
|
+
*/
|
|
10
|
+
getStatus(): Promise<ContactStatus>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=wo-contact.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wo-contact.d.ts","sourceRoot":"","sources":["../../src/devices/wo-contact.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEvD,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAE3C;;GAEG;AACH,qBAAa,SAAU,SAAQ,eAAe;IAC5C;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,aAAa,CAAC;CAqC1C"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/* Copyright(C) 2024-2026, donavanbecker (https://github.com/donavanbecker). All rights reserved.
|
|
2
|
+
*
|
|
3
|
+
* devices/wo-contact.ts: SwitchBot v4.0.0 - Contact Sensor
|
|
4
|
+
*/
|
|
5
|
+
import { SwitchBotDevice } from './base.js';
|
|
6
|
+
/**
|
|
7
|
+
* Contact Sensor (Door/Window Sensor)
|
|
8
|
+
*/
|
|
9
|
+
export class WoContact extends SwitchBotDevice {
|
|
10
|
+
/**
|
|
11
|
+
* Get device status
|
|
12
|
+
*/
|
|
13
|
+
async getStatus() {
|
|
14
|
+
try {
|
|
15
|
+
// Try API first if available
|
|
16
|
+
if (this.hasAPI()) {
|
|
17
|
+
const apiStatus = await this.getAPIStatus();
|
|
18
|
+
return {
|
|
19
|
+
deviceId: this.info.id,
|
|
20
|
+
connectionType: 'api',
|
|
21
|
+
openState: apiStatus.openState || 'closed',
|
|
22
|
+
moveDetected: apiStatus.moveDetected,
|
|
23
|
+
brightness: apiStatus.brightness,
|
|
24
|
+
battery: apiStatus.battery,
|
|
25
|
+
version: apiStatus.version,
|
|
26
|
+
updatedAt: new Date(),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
// Fallback to BLE
|
|
30
|
+
if (this.hasBLE()) {
|
|
31
|
+
const bleData = await this.getBLEStatus();
|
|
32
|
+
return {
|
|
33
|
+
deviceId: this.info.id,
|
|
34
|
+
connectionType: 'ble',
|
|
35
|
+
openState: bleData.position || 'closed',
|
|
36
|
+
moveDetected: bleData.movement,
|
|
37
|
+
brightness: bleData.lightLevel,
|
|
38
|
+
battery: bleData.battery,
|
|
39
|
+
updatedAt: new Date(),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
throw new Error('No connection method available');
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
this.logger.error('Failed to get status', error);
|
|
46
|
+
throw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,IAAI,IAAI,EAAE;iBACtB,CAAA;YACH,CAAC;YAED,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;QACnD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAA;YAChD,MAAM,KAAK,CAAA;QACb,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { CurtainCommands, CurtainStatus } from '../types/device.js';
|
|
2
|
+
import { SwitchBotDevice } from './base.js';
|
|
3
|
+
/**
|
|
4
|
+
* Curtain Device - Smart curtain controller
|
|
5
|
+
*/
|
|
6
|
+
export declare class WoCurtain extends SwitchBotDevice implements CurtainCommands {
|
|
7
|
+
/**
|
|
8
|
+
* Open curtain (position 0%)
|
|
9
|
+
*/
|
|
10
|
+
open(): Promise<boolean>;
|
|
11
|
+
/**
|
|
12
|
+
* Close curtain (position 100%)
|
|
13
|
+
*/
|
|
14
|
+
close(): Promise<boolean>;
|
|
15
|
+
/**
|
|
16
|
+
* Pause curtain movement
|
|
17
|
+
*/
|
|
18
|
+
pause(): Promise<boolean>;
|
|
19
|
+
/**
|
|
20
|
+
* Set curtain position (0-100%)
|
|
21
|
+
*/
|
|
22
|
+
setPosition(position: number): Promise<boolean>;
|
|
23
|
+
/**
|
|
24
|
+
* Get device status
|
|
25
|
+
*/
|
|
26
|
+
getStatus(): Promise<CurtainStatus>;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=wo-curtain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wo-curtain.d.ts","sourceRoot":"","sources":["../../src/devices/wo-curtain.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAIxE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAE3C;;GAEG;AACH,qBAAa,SAAU,SAAQ,eAAgB,YAAW,eAAe;IACvE;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC;IAQ9B;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC;IAQ/B;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC;IAQ/B;;OAEG;IACG,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAcrD;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,aAAa,CAAC;CAoC1C"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/* Copyright(C) 2024-2026, donavanbecker (https://github.com/donavanbecker). All rights reserved.
|
|
2
|
+
*
|
|
3
|
+
* devices/wo-curtain.ts: SwitchBot v4.0.0 - Curtain Device
|
|
4
|
+
*/
|
|
5
|
+
import { DEVICE_COMMANDS } from '../settings.js';
|
|
6
|
+
import { clamp } from '../utils/index.js';
|
|
7
|
+
import { SwitchBotDevice } from './base.js';
|
|
8
|
+
/**
|
|
9
|
+
* Curtain Device - Smart curtain controller
|
|
10
|
+
*/
|
|
11
|
+
export class WoCurtain extends SwitchBotDevice {
|
|
12
|
+
/**
|
|
13
|
+
* Open curtain (position 0%)
|
|
14
|
+
*/
|
|
15
|
+
async open() {
|
|
16
|
+
const result = await this.sendCommand(DEVICE_COMMANDS.CURTAIN.OPEN, 'turnOn');
|
|
17
|
+
return result.success;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Close curtain (position 100%)
|
|
21
|
+
*/
|
|
22
|
+
async close() {
|
|
23
|
+
const result = await this.sendCommand(DEVICE_COMMANDS.CURTAIN.CLOSE, 'turnOff');
|
|
24
|
+
return result.success;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Pause curtain movement
|
|
28
|
+
*/
|
|
29
|
+
async pause() {
|
|
30
|
+
const result = await this.sendCommand(DEVICE_COMMANDS.CURTAIN.PAUSE, 'pause');
|
|
31
|
+
return result.success;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Set curtain position (0-100%)
|
|
35
|
+
*/
|
|
36
|
+
async setPosition(position) {
|
|
37
|
+
const clampedPosition = clamp(position, 0, 100);
|
|
38
|
+
// BLE command with position byte
|
|
39
|
+
const bleCommand = [...DEVICE_COMMANDS.CURTAIN.POSITION, clampedPosition];
|
|
40
|
+
const result = await this.sendCommand(bleCommand, 'setPosition', `0,ff,${clampedPosition}`);
|
|
41
|
+
return result.success;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Get device status
|
|
45
|
+
*/
|
|
46
|
+
async getStatus() {
|
|
47
|
+
try {
|
|
48
|
+
// Try API first if available
|
|
49
|
+
if (this.hasAPI()) {
|
|
50
|
+
const apiStatus = await this.getAPIStatus();
|
|
51
|
+
return {
|
|
52
|
+
deviceId: this.info.id,
|
|
53
|
+
connectionType: 'api',
|
|
54
|
+
position: apiStatus.slidePosition || 0,
|
|
55
|
+
calibrated: apiStatus.calibrate,
|
|
56
|
+
moving: apiStatus.moving,
|
|
57
|
+
battery: apiStatus.battery,
|
|
58
|
+
version: apiStatus.version,
|
|
59
|
+
updatedAt: new Date(),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
// Fallback to BLE
|
|
63
|
+
if (this.hasBLE()) {
|
|
64
|
+
const bleData = await this.getBLEStatus();
|
|
65
|
+
return {
|
|
66
|
+
deviceId: this.info.id,
|
|
67
|
+
connectionType: 'ble',
|
|
68
|
+
position: bleData.position || 0,
|
|
69
|
+
calibrated: bleData.calibration,
|
|
70
|
+
battery: bleData.battery,
|
|
71
|
+
updatedAt: new Date(),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
throw new Error('No connection method available');
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
this.logger.error('Failed to get status', error);
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=wo-curtain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wo-curtain.js","sourceRoot":"","sources":["../../src/devices/wo-curtain.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAE3C;;GAEG;AACH,MAAM,OAAO,SAAU,SAAQ,eAAe;IAC5C;;OAEG;IACH,KAAK,CAAC,IAAI;QACR,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CACnC,eAAe,CAAC,OAAO,CAAC,IAAI,EAC5B,QAAQ,CACT,CAAA;QACD,OAAO,MAAM,CAAC,OAAO,CAAA;IACvB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,KAAK;QACT,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CACnC,eAAe,CAAC,OAAO,CAAC,KAAK,EAC7B,SAAS,CACV,CAAA;QACD,OAAO,MAAM,CAAC,OAAO,CAAA;IACvB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,KAAK;QACT,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CACnC,eAAe,CAAC,OAAO,CAAC,KAAK,EAC7B,OAAO,CACR,CAAA;QACD,OAAO,MAAM,CAAC,OAAO,CAAA;IACvB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW,CAAC,QAAgB;QAChC,MAAM,eAAe,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC,EAAE,GAAG,CAAC,CAAA;QAE/C,iCAAiC;QACjC,MAAM,UAAU,GAAG,CAAC,GAAG,eAAe,CAAC,OAAO,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAA;QAEzE,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CACnC,UAAU,EACV,aAAa,EAC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|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { BotCommands, BotStatus } from '../types/device.js';
|
|
2
|
+
import { SwitchBotDevice } from './base.js';
|
|
3
|
+
/**
|
|
4
|
+
* Bot (WoHand) Device - Press or switch button device
|
|
5
|
+
*/
|
|
6
|
+
export declare class WoHand extends SwitchBotDevice implements BotCommands {
|
|
7
|
+
/**
|
|
8
|
+
* Turn on (switch mode)
|
|
9
|
+
*/
|
|
10
|
+
turnOn(): Promise<boolean>;
|
|
11
|
+
/**
|
|
12
|
+
* Turn off (switch mode)
|
|
13
|
+
*/
|
|
14
|
+
turnOff(): Promise<boolean>;
|
|
15
|
+
/**
|
|
16
|
+
* Press (press mode)
|
|
17
|
+
*/
|
|
18
|
+
press(): Promise<boolean>;
|
|
19
|
+
/**
|
|
20
|
+
* Get device status
|
|
21
|
+
*/
|
|
22
|
+
getStatus(): Promise<BotStatus>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=wo-hand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wo-hand.d.ts","sourceRoot":"","sources":["../../src/devices/wo-hand.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAGhE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAE3C;;GAEG;AACH,qBAAa,MAAO,SAAQ,eAAgB,YAAW,WAAW;IAChE;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC;IAQhC;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;IAQjC;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC;IAQ/B;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,SAAS,CAAC;CAmCtC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/* Copyright(C) 2024-2026, donavanbecker (https://github.com/donavanbecker). All rights reserved.
|
|
2
|
+
*
|
|
3
|
+
* devices/wo-hand.ts: SwitchBot v4.0.0 - Bot (WoHand) Device
|
|
4
|
+
*/
|
|
5
|
+
import { DEVICE_COMMANDS } from '../settings.js';
|
|
6
|
+
import { SwitchBotDevice } from './base.js';
|
|
7
|
+
/**
|
|
8
|
+
* Bot (WoHand) Device - Press or switch button device
|
|
9
|
+
*/
|
|
10
|
+
export class WoHand extends SwitchBotDevice {
|
|
11
|
+
/**
|
|
12
|
+
* Turn on (switch mode)
|
|
13
|
+
*/
|
|
14
|
+
async turnOn() {
|
|
15
|
+
const result = await this.sendCommand(DEVICE_COMMANDS.BOT.TURN_ON, 'turnOn');
|
|
16
|
+
return result.success;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Turn off (switch mode)
|
|
20
|
+
*/
|
|
21
|
+
async turnOff() {
|
|
22
|
+
const result = await this.sendCommand(DEVICE_COMMANDS.BOT.TURN_OFF, 'turnOff');
|
|
23
|
+
return result.success;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Press (press mode)
|
|
27
|
+
*/
|
|
28
|
+
async press() {
|
|
29
|
+
const result = await this.sendCommand(DEVICE_COMMANDS.BOT.PRESS, 'press');
|
|
30
|
+
return result.success;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Get device status
|
|
34
|
+
*/
|
|
35
|
+
async getStatus() {
|
|
36
|
+
try {
|
|
37
|
+
// Try API first if available
|
|
38
|
+
if (this.hasAPI()) {
|
|
39
|
+
const apiStatus = await this.getAPIStatus();
|
|
40
|
+
return {
|
|
41
|
+
deviceId: this.info.id,
|
|
42
|
+
connectionType: 'api',
|
|
43
|
+
power: apiStatus.power || 'off',
|
|
44
|
+
mode: apiStatus.mode || 'press',
|
|
45
|
+
battery: apiStatus.battery,
|
|
46
|
+
version: apiStatus.version,
|
|
47
|
+
updatedAt: new Date(),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
// Fallback to BLE
|
|
51
|
+
if (this.hasBLE()) {
|
|
52
|
+
const bleData = await this.getBLEStatus();
|
|
53
|
+
return {
|
|
54
|
+
deviceId: this.info.id,
|
|
55
|
+
connectionType: 'ble',
|
|
56
|
+
power: bleData.state ? 'on' : 'off',
|
|
57
|
+
mode: bleData.mode,
|
|
58
|
+
battery: bleData.battery,
|
|
59
|
+
updatedAt: new Date(),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
throw new Error('No connection method available');
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
this.logger.error('Failed to get status', error);
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=wo-hand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wo-hand.js","sourceRoot":"","sources":["../../src/devices/wo-hand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAE3C;;GAEG;AACH,MAAM,OAAO,MAAO,SAAQ,eAAe;IACzC;;OAEG;IACH,KAAK,CAAC,MAAM;QACV,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CACnC,eAAe,CAAC,GAAG,CAAC,OAAO,EAC3B,QAAQ,CACT,CAAA;QACD,OAAO,MAAM,CAAC,OAAO,CAAA;IACvB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO;QACX,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CACnC,eAAe,CAAC,GAAG,CAAC,QAAQ,EAC5B,SAAS,CACV,CAAA;QACD,OAAO,MAAM,CAAC,OAAO,CAAA;IACvB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,KAAK;QACT,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CACnC,eAAe,CAAC,GAAG,CAAC,KAAK,EACzB,OAAO,CAC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
|
|
|
1
|
+
import type { HubStatus } from '../types/device.js';
|
|
2
|
+
import { SwitchBotDevice } from './base.js';
|
|
3
|
+
/**
|
|
4
|
+
* Hub 2 Device (Hub Mini/Hub Plus also use this)
|
|
5
|
+
*/
|
|
6
|
+
export declare class WoHub2 extends SwitchBotDevice {
|
|
7
|
+
/**
|
|
8
|
+
* Get device status
|
|
9
|
+
*/
|
|
10
|
+
getStatus(): Promise<HubStatus>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=wo-hub2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wo-hub2.d.ts","sourceRoot":"","sources":["../../src/devices/wo-hub2.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAEnD,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAE3C;;GAEG;AACH,qBAAa,MAAO,SAAQ,eAAe;IACzC;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,SAAS,CAAC;CAmCtC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/* Copyright(C) 2024-2026, donavanbecker (https://github.com/donavanbecker). All rights reserved.
|
|
2
|
+
*
|
|
3
|
+
* devices/wo-hub2.ts: SwitchBot v4.0.0 - Hub 2 Device
|
|
4
|
+
*/
|
|
5
|
+
import { SwitchBotDevice } from './base.js';
|
|
6
|
+
/**
|
|
7
|
+
* Hub 2 Device (Hub Mini/Hub Plus also use this)
|
|
8
|
+
*/
|
|
9
|
+
export class WoHub2 extends SwitchBotDevice {
|
|
10
|
+
/**
|
|
11
|
+
* Get device status
|
|
12
|
+
*/
|
|
13
|
+
async getStatus() {
|
|
14
|
+
try {
|
|
15
|
+
// Try API first if available
|
|
16
|
+
if (this.hasAPI()) {
|
|
17
|
+
const apiStatus = await this.getAPIStatus();
|
|
18
|
+
return {
|
|
19
|
+
deviceId: this.info.id,
|
|
20
|
+
connectionType: 'api',
|
|
21
|
+
temperature: apiStatus.temperature,
|
|
22
|
+
humidity: apiStatus.humidity,
|
|
23
|
+
lightLevel: apiStatus.lightLevel,
|
|
24
|
+
version: apiStatus.version,
|
|
25
|
+
updatedAt: new Date(),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
// Fallback to BLE
|
|
29
|
+
if (this.hasBLE()) {
|
|
30
|
+
const bleData = await this.getBLEStatus();
|
|
31
|
+
return {
|
|
32
|
+
deviceId: this.info.id,
|
|
33
|
+
connectionType: 'ble',
|
|
34
|
+
temperature: bleData.temperature,
|
|
35
|
+
humidity: bleData.humidity,
|
|
36
|
+
lightLevel: bleData.lightLevel,
|
|
37
|
+
updatedAt: new Date(),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
throw new Error('No connection method available');
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
this.logger.error('Failed to get status', error);
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=wo-hub2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wo-hub2.js","sourceRoot":"","sources":["../../src/devices/wo-hub2.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAE3C;;GAEG;AACH,MAAM,OAAO,MAAO,SAAQ,eAAe;IACzC;;OAEG;IACH,KAAK,CAAC,SAAS;QACb,IAAI,CAAC;YACH,6BAA6B;YAC7B,IAAI,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;gBAClB,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,YAAY,EAAE,CAAA;gBAC3C,OAAO;oBACL,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE;oBACtB,cAAc,EAAE,KAAK;oBACrB,WAAW,EAAE,SAAS,CAAC,WAAW;oBAClC,QAAQ,EAAE,SAAS,CAAC,QAAQ;oBAC5B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