PySwitchbot
A library to communicate with Switchbot
What it is and what it does
pySwitchbot is an async Python library for discovering and controlling Switchbot IoT devices via Bluetooth Low Energy. It handles device discovery, authentication (including encrypted communication for locks), and command execution for devices like smart locks and motorized curtains. The library wraps aiohttp, bleak, bleak-retry-connector, cryptography, and pyOpenSSL in an async-first API suitable for home automation integrations.
The package is in alpha status but actively maintained, with recent releases and steady development. It requires Python 3.11+ and supports Python 3.12, 3.13, and 3.14. Lock control requires retrieving encryption keys from the Switchbot account API (a one-time setup step), while other devices typically work with simpler discovery and command patterns.
Use it for:
- Automate smart lock unlock/lock operations in a home automation system by retrieving encryption keys once and reusing them.
- Discover and control motorized curtains programmatically based on time, sensors, or user input.
- Build a multi-device Switchbot controller that discovers all nearby devices and exposes them to a home automation platform.
- Integrate Switchbot devices into an async Python application without blocking on BLE communication.
- Retrieve device status and data from Switchbot devices on demand.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Async Python library to discover and control Switchbot IoT devices over Bluetooth Low Energy.
Yes, if you own Switchbot devices and want to control them from Python. The library is actively maintained, has low install friction, and uses standard async patterns. It is in alpha status, so expect occasional API changes; check the repository for any breaking changes before upgrading. No known security vulnerabilities as of the latest scan.
Install
pyswitchbot on PyPI
pip
pip install pyswitchbotuv
uv add pyswitchbotpoetry
poetry add pyswitchbotInstalling PySwitchbot
Before you install
Low friction install with a pure-Python wheel. Active maintenance with a recent release (7 days old) and steady commit history. Depends on aiohttp, bleak, bleak-retry-connector, cryptography, and pyOpenSSL—all standard async and security libraries.
License in practice
MIT license is permissive; you can use, modify, and distribute this package with minimal restrictions, including in commercial projects.
Quickstart
pip install pyswitchbot
import asyncio
from pyswitchbot.discovery import GetSwitchbotDevices
async def main():
devices = await GetSwitchbotDevices().discover()
print(devices)
asyncio.run(main())
Requires Python 3.11 or later; Bluetooth hardware and Switchbot devices in range required to discover and control.
Verify before relying
- Whether all Switchbot device types beyond locks and curtains are supported.
- Whether the library works on all operating systems or has platform-specific limitations.
- Performance and reliability characteristics when controlling multiple devices concurrently.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (<4.0,>=3.11) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 5 — aiohttp, bleak, bleak-retry-connector, cryptography, pyOpenSSL |
| Maintenance | actively maintained — 7 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 85,275/month — #13,935 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pyswitchbot-2.4.1-py3-none-any.whl
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
switchbot-apiAn async Python library for controlling…
permissive · top 15,000 on PyPI
govee-bleProvides Python bindings to discover, connect…
permissive · top 15,000 on PyPI
yalexs-bleProvides Bluetooth control of Yale and August…
copyleft · top 15,000 on PyPI
pyschlagepyschlage is a Python library for…
permissive · top 15,000 on PyPI
xiaomi-bleManages Xiaomi BLE (Bluetooth Low Energy)…
permissive · top 15,000 on PyPI
aiobmsbleAsynchronous Python library for querying…
permissive · top 15,000 on PyPI
aioblescanaioblescan listens for and parses Bluetooth Low…
permissive · top 15,000 on PyPI
tinytuyaControls and monitors Tuya WiFi smart devices…
permissive · top 15,000 on PyPI
led-bleControls generic unbranded Bluetooth LE LED…
permissive · top 15,000 on PyPI
yalexsAsync Python client library for Yale Access…
permissive · top 15,000 on PyPI