Official Xiaomi integration that brings Xiaomi IoT smart devices into Home Assistant via Xiaomi Cloud or a local central hub gateway.
rytilahti/python-miio
Python library and miiocli command-line tool for controlling Xiaomi smart home devices over the miIO and MIoT protocols.
Open-source alternative to:Mi Home
- Stars
- 4,331
- Forks
- 601
- Open issues
- 317
- Last commit
- 3 months ago
What is it?
python-miio is a Python library and accompanying command-line tool, miiocli, for controlling Xiaomi smart home appliances. It speaks Xiaomi's miIO and MIoT protocols, so a device can be queried and controlled over the local network once you know its IP address and token.
For modern MIoT devices, the generic MIoT integration reads the device's spec file to list sensors, settings and actions, and lets you change settings or trigger actions from the command line or Python code. Older miIO devices such as robot vacuums, air purifiers, fans, humidifiers and lamps are covered by dedicated device modules, and a DeviceFactory helper detects the model automatically. Tokens can be fetched from your Xiaomi cloud account with the built-in cloud command.
The project also ships simple simulators for miIO and MIoT, which help developers test code without physical hardware. It is a community project not affiliated with Xiaomi, and it is used as the basis for Home Assistant's Xiaomi integrations.
Key features
- 01Controls miIO and MIoT devices over the local network using IP address and token.
- 02Generic MIoT integration exposes status, settings and actions from device spec files.
- 03Dedicated modules cover many Xiaomi robot vacuums, air purifiers, fans, humidifiers, lamps and plugs.
- 04The miiocli command supports device info, status, setting changes and action calls.
- 05Fetches device tokens from a Xiaomi cloud account via the cloud command.
- 06Includes miIO and MIoT simulators for testing without hardware.
Use cases
- Scripting or automating Xiaomi devices from a Python program.
- Building a custom smart home integration or dashboard for Xiaomi appliances.
- Testing a miIO or MIoT client without owning the physical device.
- Querying device status and changing settings from a terminal.
Quick start
- 1
Install the library from PyPI
pip install python-miio - 2
Get your device's IP address and token (e.g. via the cloud command)
miiocli cloud - 3
Query the device to see its model and the command to control it
miiocli device --ip <ip> --token <token> info
Things to know
- Modern MIoT device support requires the git version or a pre-release until version 0.6.0 is released.
- Controlling devices requires knowing each device's IP address and token.
- This is a voluntary community project not affiliated with the device manufacturers.
- Licensed under GPL-3.0, a copyleft license.
Topics
FAQ
- What is python-miio?
- Python library and miiocli command-line tool for controlling Xiaomi smart home devices over the miIO and MIoT protocols. python-miio is a Python library and accompanying command-line tool, miiocli, for controlling Xiaomi smart home appliances. It speaks Xiaomi's miIO and MIoT protocols, so a device can be queried and controlled over the local network once you know its IP address and token.
- Is python-miio free to use? What license does it have?
- python-miio is open source under the GPL-3.0 license. Check the license terms before using it in commercial products.
- Is python-miio still maintained?
- Updated within 6 months. The last commit to python-miio was on Jul 25, 2026.
- What can I use python-miio for?
- Scripting or automating Xiaomi devices from a Python program. Building a custom smart home integration or dashboard for Xiaomi appliances. Testing a miIO or MIoT client without owning the physical device. Querying device status and changing settings from a terminal.
- How do I install python-miio?
- Install the library from PyPI: pip install python-miio Get your device's IP address and token (e.g. via the cloud command): miiocli cloud Query the device to see its model and the command to control it: miiocli device --ip <ip> --token <token> info
- Where can I get python-miio?
- The source code and installation instructions are on GitHub: https://github.com/rytilahti/python-miio
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A Windows desktop client for controlling Xiaomi Mijia smart home devices, built on the mijiaAPI library with a GUI, tray, and desktop widget.
A menu bar and iPhone app that shows your home as a live 3D model and controls its lights and air conditioners via Smart Life, Home Assistant, Hue and Apple Home.
Open source home automation platform that runs locally and puts control and privacy first, often on a Raspberry Pi or local server.
A bridge that connects Zigbee smart home devices to MQTT, so they work without the vendor's own hub or gateway.
Self-hosted home video integration platform and NVR with smart detections, streaming camera video to HomeKit, Google Home and Alexa.