A command-line tool for managing Xiaomi smart home devices via the MiOT protocol. Supports both cloud API and direct LAN control.
curl -fsSL https://raw.githubusercontent.com/xeodou/xiaomi-home-cli/main/install.sh | bashOr download a binary from the Releases page.
# Authenticate with your Xiaomi account
xiaomi-home-cli auth login
# List all devices
xiaomi-home-cli device list
# Get a device property (e.g. power status: siid=2, piid=1)
xiaomi-home-cli prop get --name "Desk Lamp" --siid 2 --piid 1
# Set a device property
xiaomi-home-cli prop set --name "Desk Lamp" --siid 2 --piid 1 --value true
# Use LAN mode (faster, no cloud round-trip)
xiaomi-home-cli prop get --name "Desk Lamp" --siid 2 --piid 1 --lan
# Self-upgrade to latest release
xiaomi-home-cli self-upgrade| Command | Subcommands | Description |
|---|---|---|
auth |
login, status |
Xiaomi OAuth authentication |
device |
list, info, spec, scan |
Device management |
device camera |
list, info, bridge, live, snapshot |
Camera device commands |
home |
list |
List homes and rooms |
scene |
list, run |
Automation scenes |
prop |
get, gets, set, sets |
MiOT device properties (--lan supported) |
action |
run, batch |
MiOT device actions (--lan supported) |
config |
show, set |
CLI configuration |
self-upgrade |
Update binary to latest GitHub release |
--json-- output as JSON--json-errors-- output errors as JSON on stderr
Most commands accept these flags to identify a device:
--did-- device ID (exact match)--name-- device name--room-- room name--model-- device model--home-- home name--first-- pick first match if ambiguous
The prop and action commands support --lan to communicate directly with devices over the local network using the miIO protocol (UDP port 54321). This is faster and works without internet access.
LAN mode requires cached device info. Run device list --force-refresh first.
Requires Go 1.22 or later.
git clone https://github.com/xeodou/xiaomi-home-cli.git
cd xiaomi-home-cli
go build -o xiaomi-home-cli ./cmd/xiaomi-home-cliCross-compile for Raspberry Pi:
GOOS=linux GOARCH=arm64 go build -o xiaomi-home-cli-linux-arm64 ./cmd/xiaomi-home-cliMIT