About this project
python-miio is a community-driven Python library and accompanying command-line tool, miiocli, for controlling Xiaomi smart appliances that speak the miIO and MIoT protocols. It is not affiliated with Xiaomi or any vendor whose devices it supports.
Installation is via pip (python-miio), or from the GitHub repository for the development version. The README notes an ongoing refactoring effort and recommends the git version or pre-releases for controlling modern MIoT devices until version 0.6.0 is released.
Getting started: miiocli can control supported devices given their IP address and token. Tokens can be fetched from a Xiaomi cloud account with the miiocli cloud command (using the micloud library), or obtained by other documented methods. A generic info command reports model, hardware and firmware versions, the supported integration class, and the exact command to use for control.
Modern MIoT devices are handled by a genericmiot integration that downloads and caches device model specification files to discover sensors, settings and actions. Common commands include status (show state and accepted values for read-write settings), set (change a setting by name), actions (list available actions) and call (execute an action).
Older miIO devices are supported through per-device modules such as roborockvacuum or fan, with each module exposing its own subcommands. Model detection is automatic but can be overridden with a --model flag when cloud connectivity is unavailable.
Troubleshooting support includes repeatable --debug/-d flags for increasing log verbosity, a troubleshooting documentation section, GitHub issues and discussions, and a Matrix chat room.
API usage: the miio module exposes all functionality. DeviceFactory.create(ip, token) performs an info query to detect the model and constructs the matching device class. Device classes can be introspected through sensors(), settings() and actions(), which return descriptor objects describing available features; not all integrations define descriptors yet.
Contributions of bug fixes, features and documentation are welcomed, with a short contributing guide provided. For developers without hardware, the project ships simple miIO and MIoT simulators for testing code.
The README lists a broad range of supported devices, including Xiaomi robot vacuums (Mi Robot Vacuum V1, S4, S4 MAX, S5, S5 MAX, S6 Pure, M1S, S7, and various Dreame and Viomi models), air purifiers, humidifiers, air conditioners, cameras, gateways, plugs, power strips, lamps and bulbs, IR remote controllers, pedestal fans, water purifiers, air quality monitors, speakers, Wi-Fi repeaters, rice cookers, fresh air systems, Yeelight lights, heaters, a curtain controller, a dishwasher, a coffee maker, a pet water dispenser and more. All MIoT devices are said to be supported through genericmiot.
Home Assistant uses this library officially for several platforms (vacuum, light, fan, switch, remote, sensor, alarm control panel, device tracker), and various custom Home Assistant components also build on it. Related projects mentioned include dustcloud, Valetudo, micloud, micloudfaker and the Xiaomi Cloud Tokens Extractor.
Comments
0 people shared their preference · Deer Point appears after 10 participants
Sign in to join the discussion.