python-miio
Python library for interfacing with Xiaomi smart appliances
What it is and what it does
python-miio is a Python library and command-line tool for communicating with Xiaomi smart home devices using their proprietary miIO and MIoT protocols. It provides both a programmatic API (via classes like RoborockVacuum and Device) and a CLI tool (miiocli) for discovering devices, querying their status, and sending control commands. The library abstracts away protocol details and handles device model detection automatically.
The package supports a wide range of Xiaomi and compatible devices—robot vacuums, air purifiers, fans, smart plugs, lights, humidifiers, and others—each exposed through a dedicated module. It is actively used by Home Assistant for official device integration. Installation is straightforward with low friction, though operation requires obtaining a device token and network access to the target device.
Use it for:
- Control a Xiaomi robot vacuum from Python or the command line without proprietary apps.
- Automate Xiaomi smart home devices in a home automation system.
- Query device status and execute device-specific commands via miiocli.
- Build custom integrations for unsupported Xiaomi devices by extending the Device or MiotDevice base classes.
- Monitor and control air purifiers, humidifiers, and environmental devices on a local network.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Python library and CLI tool for controlling Xiaomi smart devices using the miIO and MIoT protocols over the network.
Yes, if you own Xiaomi smart devices and want programmatic or CLI control without relying on cloud services or proprietary apps. The library is stable, actively maintained, and widely used. The copyleft GPL-3.0-only license is a consideration if you plan to distribute derivative work. No known security vulnerabilities as of the query date.
Install
python-miio on PyPI
pip
pip install python-miiouv
uv add python-miiopoetry
poetry add python-miioInstalling python-miio
Before you install
Low install friction with a pure Python wheel. Active maintenance as of 2026-07-25 with 4285 repository stars. Supports Python 3.7 through 3.10.
License in practice
Licensed under GPL-3.0-only (copyleft). Any derivative work or bundled distribution must also be open-source under compatible terms.
Quickstart
pip install python-miio
from miio import RoborockVacuum
vac = RoborockVacuum("", "")
vac.start()
Requires a valid device token and network connectivity to the target Xiaomi device.
Verify before relying
- Whether all 15 runtime dependencies are truly required for basic operation or if some are optional for specific device types.
- Current maintenance status beyond the last commit date—whether active development continues or the project is in maintenance-only mode.
- Specific IP address and token format requirements for device connection.
Package facts
| License | GPL-3.0-only (copyleft) |
| Python support | supports the current Python release (>=3.7,<4.0) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 15 — PyYAML, android_backup, appdirs, attrs, click, construct, croniter, cryptography, defusedxml, importlib_metadata, micloud, netifaces, pytz, tqdm, zeroconf |
| Maintenance | actively maintained — 1,488 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 329,400/month — #7,546 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: python_miio-0.5.12-py3-none-any.whl
Keywords: xiaomi, miio, miot, smart home
Tags
More Home Automation packages
Represents and manipulates IPv4, IPv6, MAC…
permissive · top 5,000 on PyPI
homeassistantHome Assistant is an open-source home…
permissive · top 5,000 on PyPI
python-statemachineDefines finite state machines and statecharts…
permissive · top 5,000 on PyPI
btsocketA Python library for controlling BlueZ…
permissive · top 15,000 on PyPI
aiohomematicAn async Python library for controlling and…
permissive · top 15,000 on PyPI
hass-web-proxy-libProvides base classes and utilities for Home…
permissive · top 15,000 on PyPI
nmclinmcli is a Python wrapper for the…
permissive · top 15,000 on PyPI
xiaomi-bleManages Xiaomi BLE (Bluetooth Low Energy)…
permissive · top 15,000 on PyPI
broadlinkA Python module and CLI for discovering,…
permissive · top 15,000 on PyPI
roombapyroombapy is a Python library for controlling…
permissive · top 15,000 on PyPI
micloudLogs into Xiaomi cloud accounts and retrieves…
permissive · top 15,000 on PyPI
tinytuyaControls and monitors Tuya WiFi smart devices…
permissive · top 15,000 on PyPI
python-roborockControl Roborock vacuum cleaners online and…
permissive · top 15,000 on PyPI
pymielepymiele is a Python library that enables Home…
permissive · top 15,000 on PyPI
wiimwiim provides a Python API to discover,…
permissive · top 15,000 on PyPI
pywemoDiscovers and controls Belkin WeMo smart home…
permissive · top 15,000 on PyPI