node-switchbot 4.0.0-beta.8 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BLE.md +215 -838
- package/CHANGELOG.md +96 -1371
- package/OpenAPI.md +169 -135
- package/README.md +1 -1
- package/dist/api.d.ts +3 -3
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +9 -6
- package/dist/api.js.map +1 -1
- package/dist/ble.d.ts +33 -1
- package/dist/ble.d.ts.map +1 -1
- package/dist/ble.js +415 -37
- package/dist/ble.js.map +1 -1
- package/dist/devices/base.d.ts +100 -1
- package/dist/devices/base.d.ts.map +1 -1
- package/dist/devices/base.js +248 -11
- package/dist/devices/base.js.map +1 -1
- package/dist/devices/device-override-state-during-connection.d.ts +27 -0
- package/dist/devices/device-override-state-during-connection.d.ts.map +1 -0
- package/dist/devices/device-override-state-during-connection.js +45 -0
- package/dist/devices/device-override-state-during-connection.js.map +1 -0
- package/dist/devices/index.d.ts +36 -0
- package/dist/devices/index.d.ts.map +1 -1
- package/dist/devices/index.js +36 -0
- package/dist/devices/index.js.map +1 -1
- package/dist/devices/sequence-device.d.ts +52 -0
- package/dist/devices/sequence-device.d.ts.map +1 -0
- package/dist/devices/sequence-device.js +91 -0
- package/dist/devices/sequence-device.js.map +1 -0
- package/dist/devices/wo-ai-hub.d.ts +9 -0
- package/dist/devices/wo-ai-hub.d.ts.map +1 -0
- package/dist/devices/wo-ai-hub.js +25 -0
- package/dist/devices/wo-ai-hub.js.map +1 -0
- package/dist/devices/wo-air-purifier-pm25.d.ts +29 -0
- package/dist/devices/wo-air-purifier-pm25.d.ts.map +1 -0
- package/dist/devices/wo-air-purifier-pm25.js +144 -0
- package/dist/devices/wo-air-purifier-pm25.js.map +1 -0
- package/dist/devices/wo-air-purifier.d.ts +21 -4
- package/dist/devices/wo-air-purifier.d.ts.map +1 -1
- package/dist/devices/wo-air-purifier.js +111 -61
- package/dist/devices/wo-air-purifier.js.map +1 -1
- package/dist/devices/wo-art-frame.d.ts +8 -0
- package/dist/devices/wo-art-frame.d.ts.map +1 -0
- package/dist/devices/wo-art-frame.js +12 -0
- package/dist/devices/wo-art-frame.js.map +1 -0
- package/dist/devices/wo-blind-tilt.d.ts +2 -16
- package/dist/devices/wo-blind-tilt.d.ts.map +1 -1
- package/dist/devices/wo-blind-tilt.js +135 -62
- package/dist/devices/wo-blind-tilt.js.map +1 -1
- package/dist/devices/wo-bulb.d.ts +37 -1
- package/dist/devices/wo-bulb.d.ts.map +1 -1
- package/dist/devices/wo-bulb.js +196 -51
- package/dist/devices/wo-bulb.js.map +1 -1
- package/dist/devices/wo-candle-warmer-lamp.d.ts +25 -0
- package/dist/devices/wo-candle-warmer-lamp.d.ts.map +1 -0
- package/dist/devices/wo-candle-warmer-lamp.js +81 -0
- package/dist/devices/wo-candle-warmer-lamp.js.map +1 -0
- package/dist/devices/wo-circulator-fan.d.ts +8 -0
- package/dist/devices/wo-circulator-fan.d.ts.map +1 -0
- package/dist/devices/wo-circulator-fan.js +12 -0
- package/dist/devices/wo-circulator-fan.js.map +1 -0
- package/dist/devices/wo-climate-panel.d.ts +8 -0
- package/dist/devices/wo-climate-panel.d.ts.map +1 -0
- package/dist/devices/wo-climate-panel.js +12 -0
- package/dist/devices/wo-climate-panel.js.map +1 -0
- package/dist/devices/wo-contact.d.ts +1 -1
- package/dist/devices/wo-contact.d.ts.map +1 -1
- package/dist/devices/wo-contact.js +19 -35
- package/dist/devices/wo-contact.js.map +1 -1
- package/dist/devices/wo-curtain.d.ts +20 -4
- package/dist/devices/wo-curtain.d.ts.map +1 -1
- package/dist/devices/wo-curtain.js +130 -35
- package/dist/devices/wo-curtain.js.map +1 -1
- package/dist/devices/wo-floor-lamp.d.ts +8 -0
- package/dist/devices/wo-floor-lamp.d.ts.map +1 -0
- package/dist/devices/wo-floor-lamp.js +12 -0
- package/dist/devices/wo-floor-lamp.js.map +1 -0
- package/dist/devices/wo-garage-door-opener.d.ts +8 -0
- package/dist/devices/wo-garage-door-opener.d.ts.map +1 -0
- package/dist/devices/wo-garage-door-opener.js +12 -0
- package/dist/devices/wo-garage-door-opener.js.map +1 -0
- package/dist/devices/wo-hand.d.ts +22 -6
- package/dist/devices/wo-hand.d.ts.map +1 -1
- package/dist/devices/wo-hand.js +55 -39
- package/dist/devices/wo-hand.js.map +1 -1
- package/dist/devices/wo-hub2.d.ts +1 -1
- package/dist/devices/wo-hub2.d.ts.map +1 -1
- package/dist/devices/wo-hub2.js +17 -33
- package/dist/devices/wo-hub2.js.map +1 -1
- package/dist/devices/wo-hubmini-matter.d.ts +8 -0
- package/dist/devices/wo-hubmini-matter.d.ts.map +1 -0
- package/dist/devices/wo-hubmini-matter.js +12 -0
- package/dist/devices/wo-hubmini-matter.js.map +1 -0
- package/dist/devices/wo-humi.d.ts +18 -2
- package/dist/devices/wo-humi.d.ts.map +1 -1
- package/dist/devices/wo-humi.js +60 -36
- package/dist/devices/wo-humi.js.map +1 -1
- package/dist/devices/wo-humi2.d.ts.map +1 -1
- package/dist/devices/wo-humi2.js.map +1 -1
- package/dist/devices/wo-keypad-vision-pro.d.ts +18 -0
- package/dist/devices/wo-keypad-vision-pro.d.ts.map +1 -0
- package/dist/devices/wo-keypad-vision-pro.js +15 -0
- package/dist/devices/wo-keypad-vision-pro.js.map +1 -0
- package/dist/devices/wo-keypad-vision.d.ts +8 -0
- package/dist/devices/wo-keypad-vision.d.ts.map +1 -0
- package/dist/devices/wo-keypad-vision.js +12 -0
- package/dist/devices/wo-keypad-vision.js.map +1 -0
- package/dist/devices/wo-keypad.d.ts +1 -1
- package/dist/devices/wo-keypad.d.ts.map +1 -1
- package/dist/devices/wo-keypad.js +14 -30
- package/dist/devices/wo-keypad.js.map +1 -1
- package/dist/devices/wo-leak.d.ts +1 -1
- package/dist/devices/wo-leak.d.ts.map +1 -1
- package/dist/devices/wo-leak.js +15 -31
- package/dist/devices/wo-leak.js.map +1 -1
- package/dist/devices/wo-lock-lite.d.ts +7 -0
- package/dist/devices/wo-lock-lite.d.ts.map +1 -0
- package/dist/devices/wo-lock-lite.js +11 -0
- package/dist/devices/wo-lock-lite.js.map +1 -0
- package/dist/devices/wo-lock-pro-wifi.d.ts +7 -0
- package/dist/devices/wo-lock-pro-wifi.d.ts.map +1 -0
- package/dist/devices/wo-lock-pro-wifi.js +11 -0
- package/dist/devices/wo-lock-pro-wifi.js.map +1 -0
- package/dist/devices/wo-lock-pro.d.ts +12 -3
- package/dist/devices/wo-lock-pro.d.ts.map +1 -1
- package/dist/devices/wo-lock-pro.js +83 -37
- package/dist/devices/wo-lock-pro.js.map +1 -1
- package/dist/devices/wo-lock-vision-pro.d.ts +7 -0
- package/dist/devices/wo-lock-vision-pro.d.ts.map +1 -0
- package/dist/devices/wo-lock-vision-pro.js +11 -0
- package/dist/devices/wo-lock-vision-pro.js.map +1 -0
- package/dist/devices/wo-lock-vision.d.ts +7 -0
- package/dist/devices/wo-lock-vision.d.ts.map +1 -0
- package/dist/devices/wo-lock-vision.js +11 -0
- package/dist/devices/wo-lock-vision.js.map +1 -0
- package/dist/devices/wo-lock.d.ts +8 -3
- package/dist/devices/wo-lock.d.ts.map +1 -1
- package/dist/devices/wo-lock.js +75 -36
- package/dist/devices/wo-lock.js.map +1 -1
- package/dist/devices/wo-pan-tilt-cam-plus-3k.d.ts +21 -0
- package/dist/devices/wo-pan-tilt-cam-plus-3k.d.ts.map +1 -0
- package/dist/devices/wo-pan-tilt-cam-plus-3k.js +87 -0
- package/dist/devices/wo-pan-tilt-cam-plus-3k.js.map +1 -0
- package/dist/devices/wo-plug-mini-us.d.ts +3 -3
- package/dist/devices/wo-plug-mini-us.d.ts.map +1 -1
- package/dist/devices/wo-plug-mini-us.js +25 -35
- package/dist/devices/wo-plug-mini-us.js.map +1 -1
- package/dist/devices/wo-presence.d.ts +1 -1
- package/dist/devices/wo-presence.d.ts.map +1 -1
- package/dist/devices/wo-presence.js +17 -33
- package/dist/devices/wo-presence.js.map +1 -1
- package/dist/devices/wo-relay-switch-1.d.ts +19 -3
- package/dist/devices/wo-relay-switch-1.d.ts.map +1 -1
- package/dist/devices/wo-relay-switch-1.js +90 -42
- package/dist/devices/wo-relay-switch-1.js.map +1 -1
- package/dist/devices/wo-relay-switch-2pm.d.ts +21 -0
- package/dist/devices/wo-relay-switch-2pm.d.ts.map +1 -0
- package/dist/devices/wo-relay-switch-2pm.js +37 -0
- package/dist/devices/wo-relay-switch-2pm.js.map +1 -0
- package/dist/devices/wo-remote-with-screen.d.ts +9 -0
- package/dist/devices/wo-remote-with-screen.d.ts.map +1 -0
- package/dist/devices/wo-remote-with-screen.js +22 -0
- package/dist/devices/wo-remote-with-screen.js.map +1 -0
- package/dist/devices/wo-remote.d.ts +1 -1
- package/dist/devices/wo-remote.d.ts.map +1 -1
- package/dist/devices/wo-remote.js +13 -29
- package/dist/devices/wo-remote.js.map +1 -1
- package/dist/devices/wo-rgbic-bulb.d.ts +29 -0
- package/dist/devices/wo-rgbic-bulb.d.ts.map +1 -0
- package/dist/devices/wo-rgbic-bulb.js +84 -0
- package/dist/devices/wo-rgbic-bulb.js.map +1 -0
- package/dist/devices/wo-rgbic-neon-wire-rope-light.d.ts +29 -0
- package/dist/devices/wo-rgbic-neon-wire-rope-light.d.ts.map +1 -0
- package/dist/devices/wo-rgbic-neon-wire-rope-light.js +113 -0
- package/dist/devices/wo-rgbic-neon-wire-rope-light.js.map +1 -0
- package/dist/devices/wo-rgbicww-floor-lamp.d.ts +8 -0
- package/dist/devices/wo-rgbicww-floor-lamp.d.ts.map +1 -0
- package/dist/devices/wo-rgbicww-floor-lamp.js +12 -0
- package/dist/devices/wo-rgbicww-floor-lamp.js.map +1 -0
- package/dist/devices/wo-rgbicww-strip-light.d.ts +8 -0
- package/dist/devices/wo-rgbicww-strip-light.d.ts.map +1 -0
- package/dist/devices/wo-rgbicww-strip-light.js +12 -0
- package/dist/devices/wo-rgbicww-strip-light.js.map +1 -0
- package/dist/devices/wo-roller-shade.d.ts +8 -0
- package/dist/devices/wo-roller-shade.d.ts.map +1 -0
- package/dist/devices/wo-roller-shade.js +12 -0
- package/dist/devices/wo-roller-shade.js.map +1 -0
- package/dist/devices/wo-sensor-th.d.ts +1 -1
- package/dist/devices/wo-sensor-th.d.ts.map +1 -1
- package/dist/devices/wo-sensor-th.js +18 -34
- package/dist/devices/wo-sensor-th.js.map +1 -1
- package/dist/devices/wo-smart-thermostat-radiator.d.ts +8 -0
- package/dist/devices/wo-smart-thermostat-radiator.d.ts.map +1 -0
- package/dist/devices/wo-smart-thermostat-radiator.js +12 -0
- package/dist/devices/wo-smart-thermostat-radiator.js.map +1 -0
- package/dist/devices/wo-strip-light-3.d.ts +8 -0
- package/dist/devices/wo-strip-light-3.d.ts.map +1 -0
- package/dist/devices/wo-strip-light-3.js +12 -0
- package/dist/devices/wo-strip-light-3.js.map +1 -0
- package/dist/devices/wo-vacuum-k10-plus.d.ts +7 -0
- package/dist/devices/wo-vacuum-k10-plus.d.ts.map +1 -0
- package/dist/devices/wo-vacuum-k10-plus.js +11 -0
- package/dist/devices/wo-vacuum-k10-plus.js.map +1 -0
- package/dist/devices/wo-vacuum-k10-pro-combo.d.ts +7 -0
- package/dist/devices/wo-vacuum-k10-pro-combo.d.ts.map +1 -0
- package/dist/devices/wo-vacuum-k10-pro-combo.js +11 -0
- package/dist/devices/wo-vacuum-k10-pro-combo.js.map +1 -0
- package/dist/devices/wo-vacuum-k10-pro.d.ts +7 -0
- package/dist/devices/wo-vacuum-k10-pro.d.ts.map +1 -0
- package/dist/devices/wo-vacuum-k10-pro.js +11 -0
- package/dist/devices/wo-vacuum-k10-pro.js.map +1 -0
- package/dist/devices/wo-vacuum-k11-plus.d.ts +7 -0
- package/dist/devices/wo-vacuum-k11-plus.d.ts.map +1 -0
- package/dist/devices/wo-vacuum-k11-plus.js +11 -0
- package/dist/devices/wo-vacuum-k11-plus.js.map +1 -0
- package/dist/devices/wo-vacuum-k20.d.ts +7 -0
- package/dist/devices/wo-vacuum-k20.d.ts.map +1 -0
- package/dist/devices/wo-vacuum-k20.js +11 -0
- package/dist/devices/wo-vacuum-k20.js.map +1 -0
- package/dist/devices/wo-vacuum-s10.d.ts +7 -0
- package/dist/devices/wo-vacuum-s10.d.ts.map +1 -0
- package/dist/devices/wo-vacuum-s10.js +11 -0
- package/dist/devices/wo-vacuum-s10.js.map +1 -0
- package/dist/devices/wo-vacuum-s20.d.ts +7 -0
- package/dist/devices/wo-vacuum-s20.d.ts.map +1 -0
- package/dist/devices/wo-vacuum-s20.js +11 -0
- package/dist/devices/wo-vacuum-s20.js.map +1 -0
- package/dist/devices/wo-vacuum.d.ts +44 -0
- package/dist/devices/wo-vacuum.d.ts.map +1 -0
- package/dist/devices/wo-vacuum.js +143 -0
- package/dist/devices/wo-vacuum.js.map +1 -0
- package/dist/devices/wo-water-detector.d.ts +9 -0
- package/dist/devices/wo-water-detector.d.ts.map +1 -0
- package/dist/devices/wo-water-detector.js +20 -0
- package/dist/devices/wo-water-detector.js.map +1 -0
- package/dist/errors.d.ts +20 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +31 -1
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/settings.d.ts +25 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +85 -6
- package/dist/settings.js.map +1 -1
- package/dist/switchbot.d.ts +1 -0
- package/dist/switchbot.d.ts.map +1 -1
- package/dist/switchbot.js +154 -34
- package/dist/switchbot.js.map +1 -1
- package/dist/types/ble.d.ts +24 -0
- package/dist/types/ble.d.ts.map +1 -1
- package/dist/types/ble.js.map +1 -1
- package/dist/types/device.d.ts +84 -5
- package/dist/types/device.d.ts.map +1 -1
- package/dist/types/index.d.ts +26 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utils/fallback-handler.js +0 -1
- package/dist/utils/fallback-handler.js.map +1 -1
- package/dist/utils/index.d.ts +21 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +49 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/relay-encryption.d.ts +10 -0
- package/dist/utils/relay-encryption.d.ts.map +1 -0
- package/dist/utils/relay-encryption.js +23 -0
- package/dist/utils/relay-encryption.js.map +1 -0
- package/dist/utils/retry.d.ts.map +1 -1
- package/dist/utils/retry.js +49 -6
- package/dist/utils/retry.js.map +1 -1
- package/package.json +30 -14
- package/.gitattributes +0 -2
- package/.github/copilot-instructions.md +0 -179
- package/.github/dependabot.yml +0 -17
- package/.github/labeler.yml +0 -38
- package/.github/npm-version-script-esm.js +0 -97
- package/.github/workflows/beta-release.yml +0 -52
- package/.github/workflows/release.yml +0 -71
- package/.github/workflows/stale.yml +0 -12
- package/PRODUCTION_READY.md +0 -135
- package/branding/Node_x_SwitchBot.svg +0 -8
- package/branding/icon.png +0 -0
- package/branding/switchbot.png +0 -0
- package/docs/.nojekyll +0 -1
- package/docs/assets/hierarchy.js +0 -1
- package/docs/assets/highlight.css +0 -85
- package/docs/assets/icons.js +0 -18
- package/docs/assets/icons.svg +0 -1
- package/docs/assets/main.js +0 -60
- package/docs/assets/navigation.js +0 -1
- package/docs/assets/search.js +0 -1
- package/docs/assets/style.css +0 -1633
- package/docs/classes/APIError.html +0 -6
- package/docs/classes/APINotAvailableError.html +0 -4
- package/docs/classes/BLEConnection.html +0 -17
- package/docs/classes/BLENotAvailableError.html +0 -4
- package/docs/classes/BLEScanner.html +0 -17
- package/docs/classes/CommandFailedError.html +0 -6
- package/docs/classes/ConnectionTimeoutError.html +0 -5
- package/docs/classes/DeviceManager.html +0 -25
- package/docs/classes/DeviceNotFoundError.html +0 -4
- package/docs/classes/DiscoveryError.html +0 -5
- package/docs/classes/OpenAPIClient.html +0 -66
- package/docs/classes/SwitchBot.html +0 -22
- package/docs/classes/SwitchBotDevice.html +0 -56
- package/docs/classes/SwitchBotError.html +0 -4
- package/docs/classes/ValidationError.html +0 -5
- package/docs/classes/WoAirPurifier.html +0 -63
- package/docs/classes/WoAirPurifierTable.html +0 -64
- package/docs/classes/WoBlindTilt.html +0 -67
- package/docs/classes/WoBulb.html +0 -65
- package/docs/classes/WoCeilingLight.html +0 -66
- package/docs/classes/WoContact.html +0 -55
- package/docs/classes/WoCurtain.html +0 -63
- package/docs/classes/WoHand.html +0 -69
- package/docs/classes/WoHub2.html +0 -55
- package/docs/classes/WoHub3.html +0 -56
- package/docs/classes/WoHumi.html +0 -63
- package/docs/classes/WoHumi2.html +0 -64
- package/docs/classes/WoIOSensorTH.html +0 -56
- package/docs/classes/WoKeypad.html +0 -56
- package/docs/classes/WoLeak.html +0 -55
- package/docs/classes/WoPlugMiniJP.html +0 -62
- package/docs/classes/WoPlugMiniUS.html +0 -61
- package/docs/classes/WoPresence.html +0 -55
- package/docs/classes/WoRelaySwitch1.html +0 -61
- package/docs/classes/WoRelaySwitch1PM.html +0 -62
- package/docs/classes/WoRemote.html +0 -56
- package/docs/classes/WoSensorTH.html +0 -55
- package/docs/classes/WoSensorTHPlus.html +0 -56
- package/docs/classes/WoSensorTHPro.html +0 -56
- package/docs/classes/WoSensorTHProCO2.html +0 -56
- package/docs/classes/WoSmartLock.html +0 -59
- package/docs/classes/WoSmartLockPro.html +0 -61
- package/docs/classes/WoStrip.html +0 -66
- package/docs/enums/LogLevel.html +0 -7
- package/docs/enums/SwitchBotBLEModel.html +0 -40
- package/docs/enums/SwitchBotBLEModelName.html +0 -40
- package/docs/functions/updateBaseURL.html +0 -3
- package/docs/hierarchy.html +0 -1
- package/docs/index.html +0 -55
- package/docs/interfaces/APICommandRequest.html +0 -5
- package/docs/interfaces/APICommandResponse.html +0 -5
- package/docs/interfaces/APIDevice.html +0 -18
- package/docs/interfaces/APIDeviceStatus.html +0 -36
- package/docs/interfaces/APIErrorResponse.html +0 -5
- package/docs/interfaces/APIResponse.html +0 -5
- package/docs/interfaces/AirPurifierCommands.html +0 -5
- package/docs/interfaces/AirPurifierServiceData.html +0 -14
- package/docs/interfaces/AirPurifierStatus.html +0 -17
- package/docs/interfaces/BLEAdvertisement.html +0 -7
- package/docs/interfaces/BLEScanOptions.html +0 -10
- package/docs/interfaces/BLEServiceData.html +0 -10
- package/docs/interfaces/BlindTiltCommands.html +0 -7
- package/docs/interfaces/BlindTiltServiceData.html +0 -14
- package/docs/interfaces/BlindTiltStatus.html +0 -15
- package/docs/interfaces/BotCommands.html +0 -4
- package/docs/interfaces/BotServiceData.html +0 -12
- package/docs/interfaces/BotStatus.html +0 -14
- package/docs/interfaces/BulbCommands.html +0 -6
- package/docs/interfaces/BulbServiceData.html +0 -19
- package/docs/interfaces/BulbStatus.html +0 -16
- package/docs/interfaces/CeilingLightCommands.html +0 -6
- package/docs/interfaces/CeilingLightServiceData.html +0 -19
- package/docs/interfaces/CeilingLightStatus.html +0 -16
- package/docs/interfaces/CommandResult.html +0 -12
- package/docs/interfaces/ContactServiceData.html +0 -13
- package/docs/interfaces/ContactStatus.html +0 -15
- package/docs/interfaces/CurtainCommands.html +0 -5
- package/docs/interfaces/CurtainServiceData.html +0 -14
- package/docs/interfaces/CurtainStatus.html +0 -17
- package/docs/interfaces/DeviceInfo.html +0 -28
- package/docs/interfaces/DeviceListResponse.html +0 -4
- package/docs/interfaces/DeviceStatus.html +0 -12
- package/docs/interfaces/DiscoveryOptions.html +0 -14
- package/docs/interfaces/HubServiceData.html +0 -14
- package/docs/interfaces/HubStatus.html +0 -15
- package/docs/interfaces/HumidifierCommands.html +0 -5
- package/docs/interfaces/HumidifierServiceData.html +0 -14
- package/docs/interfaces/HumidifierStatus.html +0 -18
- package/docs/interfaces/KeypadStatus.html +0 -13
- package/docs/interfaces/LeakServiceData.html +0 -11
- package/docs/interfaces/LeakStatus.html +0 -13
- package/docs/interfaces/LockCommands.html +0 -3
- package/docs/interfaces/LockServiceData.html +0 -15
- package/docs/interfaces/LockStatus.html +0 -15
- package/docs/interfaces/MeterServiceData.html +0 -13
- package/docs/interfaces/MeterStatus.html +0 -15
- package/docs/interfaces/MotionServiceData.html +0 -13
- package/docs/interfaces/MotionStatus.html +0 -14
- package/docs/interfaces/PlugCommands.html +0 -4
- package/docs/interfaces/PlugServiceData.html +0 -17
- package/docs/interfaces/PlugStatus.html +0 -16
- package/docs/interfaces/PresenceServiceData.html +0 -12
- package/docs/interfaces/PresenceStatus.html +0 -14
- package/docs/interfaces/RelaySwitchCommands.html +0 -4
- package/docs/interfaces/RelaySwitchServiceData.html +0 -14
- package/docs/interfaces/RelaySwitchStatus.html +0 -16
- package/docs/interfaces/RemoteStatus.html +0 -12
- package/docs/interfaces/SceneListResponse.html +0 -3
- package/docs/interfaces/StripCommands.html +0 -6
- package/docs/interfaces/StripServiceData.html +0 -19
- package/docs/interfaces/StripStatus.html +0 -16
- package/docs/interfaces/SwitchBotConfig.html +0 -30
- package/docs/interfaces/WebhookConfig.html +0 -4
- package/docs/interfaces/WebhookDetails.html +0 -7
- package/docs/interfaces/WebhookQueryResponse.html +0 -5
- package/docs/interfaces/WebhookSetupResponse.html +0 -5
- package/docs/media/BLE.md +0 -1259
- package/docs/media/OpenAPI.md +0 -186
- package/docs/modules.html +0 -1
- package/docs/types/ConnectionType.html +0 -2
- package/docs/types/PhysicalDeviceType.html +0 -2
- package/docs/types/VirtualDeviceType.html +0 -2
- package/docs/variables/urls.html +0 -1
- package/tmp-switchbot-scan.mjs +0 -79
- package/tsconfig.build.json +0 -17
|
@@ -1,70 +1,118 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
* devices/wo-relay-switch-1.ts: SwitchBot v4.0.0 - Relay Switch 1 Device
|
|
4
|
-
*/
|
|
1
|
+
import { Buffer } from 'node:buffer';
|
|
5
2
|
import { DEVICE_COMMANDS } from '../settings.js';
|
|
6
|
-
import {
|
|
3
|
+
import { validateResponseLength } from '../utils/index.js';
|
|
4
|
+
import { encryptRelayCommandIfNeeded } from '../utils/relay-encryption.js';
|
|
5
|
+
import { SequenceDevice } from './sequence-device.js';
|
|
7
6
|
/**
|
|
8
7
|
* Relay Switch 1 Device (1-channel)
|
|
9
8
|
*/
|
|
10
|
-
export class WoRelaySwitch1 extends
|
|
9
|
+
export class WoRelaySwitch1 extends SequenceDevice {
|
|
10
|
+
/**
|
|
11
|
+
* Returns true if this relay switch requires BLE encryption (encryptionKey present)
|
|
12
|
+
*/
|
|
13
|
+
needsEncryption() {
|
|
14
|
+
return !!this.info.encryptionKey;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Encrypts a command if encryption is required for this device
|
|
18
|
+
*/
|
|
19
|
+
maybeEncryptCommand(cmd) {
|
|
20
|
+
// Convert readonly arrays to mutable arrays for compatibility
|
|
21
|
+
const arr = Buffer.isBuffer(cmd) ? cmd : Buffer.from([...cmd]);
|
|
22
|
+
if (!this.needsEncryption()) {
|
|
23
|
+
return arr;
|
|
24
|
+
}
|
|
25
|
+
return encryptRelayCommandIfNeeded(arr, this.info.encryptionKey, this.info.encryptionIV);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Verifies the BLE encryption key by attempting a status read with encryption.
|
|
29
|
+
* Throws an error if the key is invalid or the device rejects the command.
|
|
30
|
+
*/
|
|
31
|
+
async verifyEncryptionKey() {
|
|
32
|
+
if (!this.needsEncryption()) {
|
|
33
|
+
throw new Error('No encryptionKey set for this device');
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
// Try to get status with encryption; if the key is wrong, device will reject or return invalid data
|
|
37
|
+
const command = this.maybeEncryptCommand([...DEVICE_COMMANDS.COMMON.POWER_ON]);
|
|
38
|
+
const result = await this.sendCommand(command, 'verifyEncryptionKey');
|
|
39
|
+
if (!result.success) {
|
|
40
|
+
throw new Error('Encryption key verification failed: device did not accept encrypted command');
|
|
41
|
+
}
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
throw new Error(`Encryption key verification failed: ${err?.message || err}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
parseRelayPowerResponse(buffer) {
|
|
49
|
+
validateResponseLength(buffer, 11, 'WoRelaySwitch1:parseRelayPowerResponse');
|
|
50
|
+
// Best-effort parsing aligned with relay basic-info responses.
|
|
51
|
+
const voltageRaw = buffer.readUInt16BE(5);
|
|
52
|
+
const currentRaw = buffer.readUInt16BE(7);
|
|
53
|
+
const energyRaw = buffer.readUInt16BE(9);
|
|
54
|
+
return {
|
|
55
|
+
voltage: voltageRaw / 10,
|
|
56
|
+
electricCurrent: currentRaw / 100,
|
|
57
|
+
electricityOfDay: energyRaw / 100,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
async getRelayPowerMonitoring() {
|
|
61
|
+
if (!this.hasBLE()) {
|
|
62
|
+
return {};
|
|
63
|
+
}
|
|
64
|
+
const result = await this.sendBLECommand(DEVICE_COMMANDS.RELAY.GET_BASIC_INFO);
|
|
65
|
+
if (!result.success || !result.data || !Buffer.isBuffer(result.data)) {
|
|
66
|
+
return {};
|
|
67
|
+
}
|
|
68
|
+
return this.parseRelayPowerResponse(result.data);
|
|
69
|
+
}
|
|
11
70
|
/**
|
|
12
71
|
* Turn on
|
|
13
72
|
*/
|
|
14
73
|
async turnOn() {
|
|
15
|
-
const
|
|
74
|
+
const command = this.maybeEncryptCommand([...DEVICE_COMMANDS.COMMON.POWER_ON]);
|
|
75
|
+
const result = await this.sendCommand(command, 'turnOn');
|
|
16
76
|
return result.success;
|
|
17
77
|
}
|
|
18
78
|
/**
|
|
19
79
|
* Turn off
|
|
20
80
|
*/
|
|
21
81
|
async turnOff() {
|
|
22
|
-
const
|
|
82
|
+
const command = this.maybeEncryptCommand([...DEVICE_COMMANDS.COMMON.POWER_OFF]);
|
|
83
|
+
const result = await this.sendCommand(command, 'turnOff');
|
|
23
84
|
return result.success;
|
|
24
85
|
}
|
|
25
86
|
/**
|
|
26
87
|
* Toggle power
|
|
27
88
|
*/
|
|
28
89
|
async toggle() {
|
|
29
|
-
const
|
|
90
|
+
const command = this.maybeEncryptCommand([...DEVICE_COMMANDS.PLUG.TOGGLE]);
|
|
91
|
+
const result = await this.sendCommand(command, 'toggle');
|
|
30
92
|
return result.success;
|
|
31
93
|
}
|
|
32
94
|
/**
|
|
33
|
-
* Get device status
|
|
95
|
+
* Get device status (BLE-first, API-fallback)
|
|
34
96
|
*/
|
|
35
97
|
async getStatus() {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return {
|
|
55
|
-
deviceId: this.info.id,
|
|
56
|
-
connectionType: 'ble',
|
|
57
|
-
power: bleData.state ? 'on' : 'off',
|
|
58
|
-
voltage: bleData.voltage,
|
|
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
|
-
}
|
|
98
|
+
return this.getStatusWithFallback(bleData => ({
|
|
99
|
+
deviceId: this.info.id,
|
|
100
|
+
connectionType: 'ble',
|
|
101
|
+
power: bleData.state ? 'on' : 'off',
|
|
102
|
+
voltage: bleData.voltage,
|
|
103
|
+
electricCurrent: bleData.electricCurrent,
|
|
104
|
+
electricityOfDay: bleData.electricityOfDay,
|
|
105
|
+
updatedAt: new Date(),
|
|
106
|
+
}), apiStatus => ({
|
|
107
|
+
deviceId: this.info.id,
|
|
108
|
+
connectionType: 'api',
|
|
109
|
+
power: apiStatus.power || 'off',
|
|
110
|
+
voltage: apiStatus.voltage,
|
|
111
|
+
electricCurrent: apiStatus.electricCurrent,
|
|
112
|
+
electricityOfDay: apiStatus.electricityOfDay,
|
|
113
|
+
version: apiStatus.version,
|
|
114
|
+
updatedAt: new Date(),
|
|
115
|
+
}));
|
|
68
116
|
}
|
|
69
117
|
}
|
|
70
118
|
//# sourceMappingURL=wo-relay-switch-1.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wo-relay-switch-1.js","sourceRoot":"","sources":["../../src/devices/wo-relay-switch-1.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wo-relay-switch-1.js","sourceRoot":"","sources":["../../src/devices/wo-relay-switch-1.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAC1D,OAAO,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAA;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAErD;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,cAAc;IAChD;;OAEG;IACK,eAAe;QACrB,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAA;IAClC,CAAC;IAED;;OAEG;IACO,mBAAmB,CAAC,GAA+B;QAC3D,8DAA8D;QAC9D,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAA;QAC9D,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,EAAE,CAAC;YAC5B,OAAO,GAAG,CAAA;QACZ,CAAC;QACD,OAAO,2BAA2B,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,aAAc,EAAE,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;IAC3F,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,mBAAmB;QACvB,IAA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AC,EAAE,CAAC,CAAC;YACV,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE;YACtB,cAAc,EAAE,KAAK;YACrB,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK;YACnC,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,eAAe,EAAE,OAAO,CAAC,eAAe;YACxC,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;YAC1C,SAAS,EAAE,IAAI,IAAI,EAAE;SACtB,CAAC,EACF,SAAS,CAAC,EAAE,CAAC,CAAC;YACZ,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE;YACtB,cAAc,EAAE,KAAK;YACrB,KAAK,EAAE,SAAS,CAAC,KAAK,IAAI,KAAK;YAC/B,OAAO,EAAE,SAAS,CAAC,OAAO;YAC1B,eAAe,EAAE,SAAS,CAAC,eAAe;YAC1C,gBAAgB,EAAE,SAAS,CAAC,gBAAgB;YAC5C,OAAO,EAAE,SAAS,CAAC,OAAO;YAC1B,SAAS,EAAE,IAAI,IAAI,EAAE;SACtB,CAAC,CACH,CAAA;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { RelaySwitchChannelCommands, RelaySwitchStatus } from '../types/device.js';
|
|
2
|
+
import { WoRelaySwitch1 } from './wo-relay-switch-1.js';
|
|
3
|
+
/**
|
|
4
|
+
* Relay Switch 2PM Device (2-channel with power monitoring)
|
|
5
|
+
* Extends Relay Switch 1 with channel-specific control
|
|
6
|
+
*/
|
|
7
|
+
export declare class WoRelaySwitch2PM extends WoRelaySwitch1 implements RelaySwitchChannelCommands {
|
|
8
|
+
/**
|
|
9
|
+
* Set channel 1 state
|
|
10
|
+
*/
|
|
11
|
+
setChannel1(state: boolean): Promise<boolean>;
|
|
12
|
+
/**
|
|
13
|
+
* Set channel 2 state
|
|
14
|
+
*/
|
|
15
|
+
setChannel2(state: boolean): Promise<boolean>;
|
|
16
|
+
/**
|
|
17
|
+
* Get device status (inherited, same as 1PM)
|
|
18
|
+
*/
|
|
19
|
+
getStatus(): Promise<RelaySwitchStatus>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=wo-relay-switch-2pm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wo-relay-switch-2pm.d.ts","sourceRoot":"","sources":["../../src/devices/wo-relay-switch-2pm.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAGvF,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAEvD;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,cAAe,YAAW,0BAA0B;IACxF;;OAEG;IACG,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAOnD;;OAEG;IACG,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAOnD;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,iBAAiB,CAAC;CAG9C"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/* Copyright(C) 2024-2026, donavanbecker (https://github.com/donavanbecker). All rights reserved.
|
|
2
|
+
*
|
|
3
|
+
* devices/wo-relay-switch-2pm.ts: SwitchBot v4.0.0 - Relay Switch 2PM Device
|
|
4
|
+
*/
|
|
5
|
+
import { DEVICE_COMMANDS } from '../settings.js';
|
|
6
|
+
import { WoRelaySwitch1 } from './wo-relay-switch-1.js';
|
|
7
|
+
/**
|
|
8
|
+
* Relay Switch 2PM Device (2-channel with power monitoring)
|
|
9
|
+
* Extends Relay Switch 1 with channel-specific control
|
|
10
|
+
*/
|
|
11
|
+
export class WoRelaySwitch2PM extends WoRelaySwitch1 {
|
|
12
|
+
/**
|
|
13
|
+
* Set channel 1 state
|
|
14
|
+
*/
|
|
15
|
+
async setChannel1(state) {
|
|
16
|
+
const raw = state ? DEVICE_COMMANDS.RELAY.CHANNEL1_ON : DEVICE_COMMANDS.RELAY.CHANNEL1_OFF;
|
|
17
|
+
const command = this.maybeEncryptCommand([...raw]);
|
|
18
|
+
const result = await this.sendCommand(command, `setChannel1:${state}`);
|
|
19
|
+
return result.success;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Set channel 2 state
|
|
23
|
+
*/
|
|
24
|
+
async setChannel2(state) {
|
|
25
|
+
const raw = state ? DEVICE_COMMANDS.RELAY.CHANNEL2_ON : DEVICE_COMMANDS.RELAY.CHANNEL2_OFF;
|
|
26
|
+
const command = this.maybeEncryptCommand([...raw]);
|
|
27
|
+
const result = await this.sendCommand(command, `setChannel2:${state}`);
|
|
28
|
+
return result.success;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Get device status (inherited, same as 1PM)
|
|
32
|
+
*/
|
|
33
|
+
async getStatus() {
|
|
34
|
+
return super.getStatus();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=wo-relay-switch-2pm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wo-relay-switch-2pm.js","sourceRoot":"","sources":["../../src/devices/wo-relay-switch-2pm.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAEvD;;;GAGG;AACH,MAAM,OAAO,gBAAiB,SAAQ,cAAc;IAClD;;OAEG;IACH,KAAK,CAAC,WAAW,CAAC,KAAc;QAC9B,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC,YAAY,CAAA;QAC1F,MAAM,OAAO,GAAG,IAAI,CAAC,mBAAmB,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAA;QAClD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,eAAe,KAAK,EAAE,CAAC,CAAA;QACtE,OAAO,MAAM,CAAC,OAAO,CAAA;IACvB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW,CAAC,KAAc;QAC9B,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC,YAAY,CAAA;QAC1F,MAAM,OAAO,GAAG,IAAI,CAAC,mBAAmB,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAA;QAClD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,eAAe,KAAK,EAAE,CAAC,CAAA;QACtE,OAAO,MAAM,CAAC,OAAO,CAAA;IACvB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,SAAS;QACb,OAAO,KAAK,CAAC,SAAS,EAAE,CAAA;IAC1B,CAAC;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DeviceStatus } from '../types/index.js';
|
|
2
|
+
import { SwitchBotDevice } from './base.js';
|
|
3
|
+
export declare class WoRemoteWithScreen extends SwitchBotDevice {
|
|
4
|
+
/**
|
|
5
|
+
* Get device status (BLE-first, API-fallback)
|
|
6
|
+
*/
|
|
7
|
+
getStatus(): Promise<DeviceStatus>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=wo-remote-with-screen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wo-remote-with-screen.d.ts","sourceRoot":"","sources":["../../src/devices/wo-remote-with-screen.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAErD,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAE3C,qBAAa,kBAAmB,SAAQ,eAAe;IACrD;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,YAAY,CAAC;CAkBzC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SwitchBotDevice } from './base.js';
|
|
2
|
+
export class WoRemoteWithScreen extends SwitchBotDevice {
|
|
3
|
+
/**
|
|
4
|
+
* Get device status (BLE-first, API-fallback)
|
|
5
|
+
*/
|
|
6
|
+
async getStatus() {
|
|
7
|
+
return this.getStatusWithFallback(bleData => ({
|
|
8
|
+
deviceId: this.info.id,
|
|
9
|
+
connectionType: 'ble',
|
|
10
|
+
updatedAt: new Date(),
|
|
11
|
+
battery: bleData.battery,
|
|
12
|
+
version: bleData.version,
|
|
13
|
+
}), apiStatus => ({
|
|
14
|
+
deviceId: this.info.id,
|
|
15
|
+
connectionType: 'api',
|
|
16
|
+
updatedAt: new Date(),
|
|
17
|
+
battery: apiStatus.battery,
|
|
18
|
+
version: apiStatus.version,
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=wo-remote-with-screen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wo-remote-with-screen.js","sourceRoot":"","sources":["../../src/devices/wo-remote-with-screen.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAE3C,MAAM,OAAO,kBAAmB,SAAQ,eAAe;IACrD;;OAEG;IACH,KAAK,CAAC,SAAS;QACb,OAAO,IAAI,CAAC,qBAAqB,CAC/B,OAAO,CAAC,EAAE,CAAC,CAAC;YACV,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE;YACtB,cAAc,EAAE,KAAK;YACrB,SAAS,EAAE,IAAI,IAAI,EAAE;YACrB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,OAAO,EAAE,OAAO,CAAC,OAAO;SACzB,CAAC,EACF,SAAS,CAAC,EAAE,CAAC,CAAC;YACZ,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE;YACtB,cAAc,EAAE,KAAK;YACrB,SAAS,EAAE,IAAI,IAAI,EAAE;YACrB,OAAO,EAAE,SAAS,CAAC,OAAO;YAC1B,OAAO,EAAE,SAAS,CAAC,OAAO;SAC3B,CAAC,CACH,CAAA;IACH,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wo-remote.d.ts","sourceRoot":"","sources":["../../src/devices/wo-remote.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEtD,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAE3C;;;GAGG;AACH,qBAAa,QAAS,SAAQ,eAAe;IAC3C;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"wo-remote.d.ts","sourceRoot":"","sources":["../../src/devices/wo-remote.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEtD,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAE3C;;;GAGG;AACH,qBAAa,QAAS,SAAQ,eAAe;IAC3C;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,YAAY,CAAC;CAiBzC"}
|
|
@@ -9,37 +9,21 @@ import { SwitchBotDevice } from './base.js';
|
|
|
9
9
|
*/
|
|
10
10
|
export class WoRemote extends SwitchBotDevice {
|
|
11
11
|
/**
|
|
12
|
-
* Get device status
|
|
12
|
+
* Get device status (BLE-first, API-fallback)
|
|
13
13
|
*/
|
|
14
14
|
async getStatus() {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
// Fallback to BLE
|
|
28
|
-
if (this.hasBLE()) {
|
|
29
|
-
const bleData = await this.getBLEStatus();
|
|
30
|
-
return {
|
|
31
|
-
deviceId: this.info.id,
|
|
32
|
-
connectionType: 'ble',
|
|
33
|
-
battery: bleData.battery,
|
|
34
|
-
updatedAt: new Date(),
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
throw new Error('No connection method available');
|
|
38
|
-
}
|
|
39
|
-
catch (error) {
|
|
40
|
-
this.logger.error('Failed to get status', error);
|
|
41
|
-
throw error;
|
|
42
|
-
}
|
|
15
|
+
return this.getStatusWithFallback(bleData => ({
|
|
16
|
+
deviceId: this.info.id,
|
|
17
|
+
connectionType: 'ble',
|
|
18
|
+
battery: bleData.battery,
|
|
19
|
+
updatedAt: new Date(),
|
|
20
|
+
}), apiStatus => ({
|
|
21
|
+
deviceId: this.info.id,
|
|
22
|
+
connectionType: 'api',
|
|
23
|
+
battery: apiStatus.battery,
|
|
24
|
+
version: apiStatus.version,
|
|
25
|
+
updatedAt: new Date(),
|
|
26
|
+
}));
|
|
43
27
|
}
|
|
44
28
|
}
|
|
45
29
|
//# sourceMappingURL=wo-remote.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wo-remote.js","sourceRoot":"","sources":["../../src/devices/wo-remote.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAE3C;;;GAGG;AACH,MAAM,OAAO,QAAS,SAAQ,eAAe;IAC3C;;OAEG;IACH,KAAK,CAAC,SAAS;QACb,IAAI,CAAC
|
|
1
|
+
{"version":3,"file":"wo-remote.js","sourceRoot":"","sources":["../../src/devices/wo-remote.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAE3C;;;GAGG;AACH,MAAM,OAAO,QAAS,SAAQ,eAAe;IAC3C;;OAEG;IACH,KAAK,CAAC,SAAS;QACb,OAAO,IAAI,CAAC,qBAAqB,CAC/B,OAAO,CAAC,EAAE,CAAC,CAAC;YACV,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE;YACtB,cAAc,EAAE,KAAK;YACrB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,SAAS,EAAE,IAAI,IAAI,EAAE;SACtB,CAAC,EACF,SAAS,CAAC,EAAE,CAAC,CAAC;YACZ,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE;YACtB,cAAc,EAAE,KAAK;YACrB,OAAO,EAAE,SAAS,CAAC,OAAO;YAC1B,OAAO,EAAE,SAAS,CAAC,OAAO;YAC1B,SAAS,EAAE,IAAI,IAAI,EAAE;SACtB,CAAC,CACH,CAAA;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { RGBICBulbCommands, RGBICBulbStatus } from '../types/device.js';
|
|
2
|
+
import { WoBulb } from './wo-bulb.js';
|
|
3
|
+
/**
|
|
4
|
+
* RGBIC Bulb Device with segmented/multi-zone color control
|
|
5
|
+
* Supports individual LED segment control for addressable RGB+IC strips
|
|
6
|
+
*/
|
|
7
|
+
export declare class WoRGBICBulb extends WoBulb implements RGBICBulbCommands {
|
|
8
|
+
private static readonly RGBIC_EFFECTS;
|
|
9
|
+
/**
|
|
10
|
+
* Set color for individual LED segment
|
|
11
|
+
* @param segmentId - Segment identifier (0-based index)
|
|
12
|
+
* @param red - Red value (0-255)
|
|
13
|
+
* @param green - Green value (0-255)
|
|
14
|
+
* @param blue - Blue value (0-255)
|
|
15
|
+
*/
|
|
16
|
+
setSegmentColor(segmentId: number, red: number, green: number, blue: number): Promise<boolean>;
|
|
17
|
+
/**
|
|
18
|
+
* Set effect for individual LED segment
|
|
19
|
+
* @param segmentId - Segment identifier (0-based index)
|
|
20
|
+
* @param effectName - Effect name from RGBIC_EFFECTS
|
|
21
|
+
* @param speed - Effect speed (1-100, default: 50)
|
|
22
|
+
*/
|
|
23
|
+
setSegmentEffect(segmentId: number, effectName: string, speed?: number): Promise<boolean>;
|
|
24
|
+
/**
|
|
25
|
+
* Get device status (inherited from WoBulb, centralized fallback)
|
|
26
|
+
*/
|
|
27
|
+
getStatus(): Promise<RGBICBulbStatus>;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=wo-rgbic-bulb.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wo-rgbic-bulb.d.ts","sourceRoot":"","sources":["../../src/devices/wo-rgbic-bulb.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAG5E,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAErC;;;GAGG;AACH,qBAAa,WAAY,SAAQ,MAAO,YAAW,iBAAiB;IAClE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CA4BpC;IAED;;;;;;OAMG;IACG,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAkBpG;;;;;OAKG;IACG,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,SAAK,GAAG,OAAO,CAAC,OAAO,CAAC;IAoB3F;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,eAAe,CAAC;CAG5C"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/* Copyright(C) 2024-2026, donavanbecker (https://github.com/donavanbecker). All rights reserved.
|
|
2
|
+
*
|
|
3
|
+
* devices/wo-rgbic-bulb.ts: SwitchBot v4.0.0 - RGBIC Color Bulb with Segmented Control
|
|
4
|
+
*/
|
|
5
|
+
import { clamp } from '../utils/index.js';
|
|
6
|
+
import { WoBulb } from './wo-bulb.js';
|
|
7
|
+
/**
|
|
8
|
+
* RGBIC Bulb Device with segmented/multi-zone color control
|
|
9
|
+
* Supports individual LED segment control for addressable RGB+IC strips
|
|
10
|
+
*/
|
|
11
|
+
export class WoRGBICBulb extends WoBulb {
|
|
12
|
+
static RGBIC_EFFECTS = {
|
|
13
|
+
// Standard effects (compatible with WoBulb)
|
|
14
|
+
christmas: 0x00,
|
|
15
|
+
candle: 0x01,
|
|
16
|
+
halloween: 0x02,
|
|
17
|
+
sunset: 0x03,
|
|
18
|
+
party: 0x04,
|
|
19
|
+
reading: 0x05,
|
|
20
|
+
rainbow: 0x06,
|
|
21
|
+
forest: 0x07,
|
|
22
|
+
ocean: 0x08,
|
|
23
|
+
spring: 0x09,
|
|
24
|
+
summer: 0x0A,
|
|
25
|
+
autumn: 0x0B,
|
|
26
|
+
winter: 0x0C,
|
|
27
|
+
aurora: 0x0D,
|
|
28
|
+
meteor: 0x0E,
|
|
29
|
+
firework: 0x0F,
|
|
30
|
+
breathe: 0x10,
|
|
31
|
+
pulse: 0x11,
|
|
32
|
+
flicker: 0x12,
|
|
33
|
+
pet: 0x13,
|
|
34
|
+
// RGBIC-specific effects
|
|
35
|
+
segment_cycle: 0x20,
|
|
36
|
+
segment_wave: 0x21,
|
|
37
|
+
segment_chase: 0x22,
|
|
38
|
+
segment_strobe: 0x23,
|
|
39
|
+
segment_twinkle: 0x24,
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Set color for individual LED segment
|
|
43
|
+
* @param segmentId - Segment identifier (0-based index)
|
|
44
|
+
* @param red - Red value (0-255)
|
|
45
|
+
* @param green - Green value (0-255)
|
|
46
|
+
* @param blue - Blue value (0-255)
|
|
47
|
+
*/
|
|
48
|
+
async setSegmentColor(segmentId, red, green, blue) {
|
|
49
|
+
const segId = clamp(segmentId, 0, 255);
|
|
50
|
+
const r = clamp(red, 0, 255);
|
|
51
|
+
const g = clamp(green, 0, 255);
|
|
52
|
+
const b = clamp(blue, 0, 255);
|
|
53
|
+
// Command format for segment color: varies by device
|
|
54
|
+
// Using extended command format: 0x57 0x0F 0x47 0x01 0x13 SEG_ID R G B
|
|
55
|
+
const bleCommand = [0x57, 0x0F, 0x47, 0x01, 0x13, segId, r, g, b];
|
|
56
|
+
const result = await this.sendCommand(bleCommand, 'setSegmentColor', `seg${segId}:${r}:${g}:${b}`);
|
|
57
|
+
return result.success;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Set effect for individual LED segment
|
|
61
|
+
* @param segmentId - Segment identifier (0-based index)
|
|
62
|
+
* @param effectName - Effect name from RGBIC_EFFECTS
|
|
63
|
+
* @param speed - Effect speed (1-100, default: 50)
|
|
64
|
+
*/
|
|
65
|
+
async setSegmentEffect(segmentId, effectName, speed = 50) {
|
|
66
|
+
const effectId = WoRGBICBulb.RGBIC_EFFECTS[effectName.toLowerCase()];
|
|
67
|
+
if (effectId === undefined) {
|
|
68
|
+
throw new Error(`Unsupported RGBIC effect: ${effectName}`);
|
|
69
|
+
}
|
|
70
|
+
const segId = clamp(segmentId, 0, 255);
|
|
71
|
+
const effectSpeed = clamp(speed, 1, 100);
|
|
72
|
+
// Command format for segment effect: 0x57 0x0F 0x47 0x01 0x14 SEG_ID EFFECT_ID SPEED
|
|
73
|
+
const bleCommand = [0x57, 0x0F, 0x47, 0x01, 0x14, segId, effectId, effectSpeed];
|
|
74
|
+
const result = await this.sendCommand(bleCommand, 'setSegmentEffect', `seg${segId}:${effectName}:${effectSpeed}`);
|
|
75
|
+
return result.success;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Get device status (inherited from WoBulb, centralized fallback)
|
|
79
|
+
*/
|
|
80
|
+
async getStatus() {
|
|
81
|
+
return super.getStatus();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=wo-rgbic-bulb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wo-rgbic-bulb.js","sourceRoot":"","sources":["../../src/devices/wo-rgbic-bulb.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,KAAK,EAAE,MAAM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
+
import type { RGBICBulbStatus } from '../types/device.js';
|
|
2
|
+
import { SwitchBotDevice } from './base.js';
|
|
3
|
+
export declare class WoRGBICNeonWireRopeLight extends SwitchBotDevice {
|
|
4
|
+
/**
|
|
5
|
+
* Get device status (BLE-first/API-fallback, centralized)
|
|
6
|
+
*/
|
|
7
|
+
getStatus(): Promise<RGBICBulbStatus>;
|
|
8
|
+
/**
|
|
9
|
+
* Turn on the neon wire rope light
|
|
10
|
+
*/
|
|
11
|
+
turnOn(): Promise<boolean>;
|
|
12
|
+
/**
|
|
13
|
+
* Turn off the neon wire rope light
|
|
14
|
+
*/
|
|
15
|
+
turnOff(): Promise<boolean>;
|
|
16
|
+
/**
|
|
17
|
+
* Set brightness (1-100)
|
|
18
|
+
*/
|
|
19
|
+
setBrightness(level: number): Promise<boolean>;
|
|
20
|
+
/**
|
|
21
|
+
* Set color (RGB)
|
|
22
|
+
*/
|
|
23
|
+
setColor(red: number, green: number, blue: number): Promise<boolean>;
|
|
24
|
+
/**
|
|
25
|
+
* Set color temperature (Kelvin)
|
|
26
|
+
*/
|
|
27
|
+
setColorTemperature(temperature: number): Promise<boolean>;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=wo-rgbic-neon-wire-rope-light.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wo-rgbic-neon-wire-rope-light.d.ts","sourceRoot":"","sources":["../../src/devices/wo-rgbic-neon-wire-rope-light.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAIzD,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAE3C,qBAAa,wBAAyB,SAAQ,eAAe;IAC3D;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,eAAe,CAAC;IAuB3C;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC;IAehC;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;IAejC;;OAEG;IACG,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAgBpD;;OAEG;IACG,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAe1E;;OAEG;IACG,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAcjE"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { Buffer } from 'node:buffer';
|
|
2
|
+
import { SwitchBotDevice } from './base.js';
|
|
3
|
+
export class WoRGBICNeonWireRopeLight extends SwitchBotDevice {
|
|
4
|
+
/**
|
|
5
|
+
* Get device status (BLE-first/API-fallback, centralized)
|
|
6
|
+
*/
|
|
7
|
+
async getStatus() {
|
|
8
|
+
return this.getStatusWithFallback(bleData => ({
|
|
9
|
+
deviceId: this.info.id,
|
|
10
|
+
connectionType: 'ble',
|
|
11
|
+
updatedAt: new Date(),
|
|
12
|
+
power: bleData.state ? 'on' : 'off',
|
|
13
|
+
brightness: bleData.brightness,
|
|
14
|
+
colorTemperature: bleData.colorTemperature,
|
|
15
|
+
color: bleData.red !== undefined ? { r: bleData.red, g: bleData.green, b: bleData.blue } : undefined,
|
|
16
|
+
}), apiStatus => ({
|
|
17
|
+
deviceId: this.info.id,
|
|
18
|
+
connectionType: 'api',
|
|
19
|
+
updatedAt: new Date(),
|
|
20
|
+
power: apiStatus.power,
|
|
21
|
+
brightness: apiStatus.brightness,
|
|
22
|
+
colorTemperature: apiStatus.colorTemperature,
|
|
23
|
+
color: apiStatus.color,
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Turn on the neon wire rope light
|
|
28
|
+
*/
|
|
29
|
+
async turnOn() {
|
|
30
|
+
if (this.hasBLE()) {
|
|
31
|
+
const command = Buffer.from([0x57, 0x01, 0x01]);
|
|
32
|
+
const result = await this.sendCommand(command, 'turnOn');
|
|
33
|
+
if (result.success) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (this.hasAPI()) {
|
|
38
|
+
const result = await this.sendAPICommand('turnOn');
|
|
39
|
+
return result.success;
|
|
40
|
+
}
|
|
41
|
+
throw new Error('No connection method available');
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Turn off the neon wire rope light
|
|
45
|
+
*/
|
|
46
|
+
async turnOff() {
|
|
47
|
+
if (this.hasBLE()) {
|
|
48
|
+
const command = Buffer.from([0x57, 0x01, 0x02]);
|
|
49
|
+
const result = await this.sendCommand(command, 'turnOff');
|
|
50
|
+
if (result.success) {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (this.hasAPI()) {
|
|
55
|
+
const result = await this.sendAPICommand('turnOff');
|
|
56
|
+
return result.success;
|
|
57
|
+
}
|
|
58
|
+
throw new Error('No connection method available');
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Set brightness (1-100)
|
|
62
|
+
*/
|
|
63
|
+
async setBrightness(level) {
|
|
64
|
+
const clamped = Math.max(1, Math.min(100, level));
|
|
65
|
+
if (this.hasBLE()) {
|
|
66
|
+
const command = Buffer.from([0x57, 0x02, clamped]);
|
|
67
|
+
const result = await this.sendCommand(command, 'setBrightness', clamped);
|
|
68
|
+
if (result.success) {
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (this.hasAPI()) {
|
|
73
|
+
const result = await this.sendAPICommand('setBrightness', clamped);
|
|
74
|
+
return result.success;
|
|
75
|
+
}
|
|
76
|
+
throw new Error('No connection method available');
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Set color (RGB)
|
|
80
|
+
*/
|
|
81
|
+
async setColor(red, green, blue) {
|
|
82
|
+
if (this.hasBLE()) {
|
|
83
|
+
const command = Buffer.from([0x57, 0x03, red, green, blue]);
|
|
84
|
+
const result = await this.sendCommand(command, 'setColor', { red, green, blue });
|
|
85
|
+
if (result.success) {
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (this.hasAPI()) {
|
|
90
|
+
const result = await this.sendAPICommand('setColor', { red, green, blue });
|
|
91
|
+
return result.success;
|
|
92
|
+
}
|
|
93
|
+
throw new Error('No connection method available');
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Set color temperature (Kelvin)
|
|
97
|
+
*/
|
|
98
|
+
async setColorTemperature(temperature) {
|
|
99
|
+
if (this.hasBLE()) {
|
|
100
|
+
const command = Buffer.from([0x57, 0x04, temperature & 0xFF, (temperature >> 8) & 0xFF]);
|
|
101
|
+
const result = await this.sendCommand(command, 'setColorTemperature', temperature);
|
|
102
|
+
if (result.success) {
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (this.hasAPI()) {
|
|
107
|
+
const result = await this.sendAPICommand('setColorTemperature', temperature);
|
|
108
|
+
return result.success;
|
|
109
|
+
}
|
|
110
|
+
throw new Error('No connection method available');
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=wo-rgbic-neon-wire-rope-light.js.map
|