python-miio talks to Xiaomi smart appliances over miIO and MIoT. The miiocli tool and DeviceFactory API control devices from the shell or from code.
Overview
python-miio is a community library for Xiaomi ecosystem hardware. It sends miIO and MIoT protocol commands so scripts and integrations can read sensors, change settings, and invoke device actions when you know each unit IP address and token.
The miiocli entry point lists cloud-discovered devices, prints firmware metadata, and routes control through device-specific modules or genericmiot. The generic path downloads miot spec files per model, then exposes status, set, and call commands that mirror available properties and actions.
Python code imports DeviceFactory to auto-detect models and introspect sensors, settings, and actions through descriptor objects. Dozens of named device classes cover vacuums, purifiers, plugs, fans, and cameras, while newer MIoT products fall back to the generic integration in the git and pre-release lines.
Simulators for miIO and MIoT ship with miiocli so developers can test integrations without physical hardware. Home Assistant is listed as a consumer of the library for several platforms.
Key features
- miIO and MIoT protocol support
- miiocli shell control for devices
- genericmiot auto spec downloads
- DeviceFactory model auto-detection
- Built-in miIO and MIoT simulators
- Cloud token lookup via miiocli cloud
- Descriptor introspection for features
- Many named Xiaomi device integrations
Use cases
- Scripting Xiaomi vacuums and air purifiers
- Building Home Assistant device integrations
- Debugging MIoT devices without vendor apps
- Teaching miIO protocol clients with simulators