Skip to main content

Async Python client for Xiaomi / MiWiFi routers over the LuCI HTTP API

Project description

python-xiaomi-miwifi

Tests PyPI version Python License: MIT

Async Python client for Xiaomi / MiWiFi routers over their LuCI HTTP API. Built to power the ha-xiaomi-miwifi Home Assistant integration.

Features

  • 🔐 Token login with the MiWiFi sha1(nonce + sha1(password + key)) signing scheme
  • 📊 Aggregated status: WAN, throughput, client counts per band, firmware, mesh topology
  • 🕸️ Mesh-aware: enumerates gateway + leaf nodes
  • 🛠️ Controls: reboot, per-radio enable/disable, DHCP reservation add/remove
  • ⚡ Fully async (aiohttp), typed (py.typed), zero-config session management

Installation

pip install python-xiaomi-miwifi

Quickstart

import asyncio
from xiaomi_miwifi import MiWiFiClient


async def main() -> None:
    async with MiWiFiClient("192.168.31.1", password="your-password") as client:
        status = await client.async_get_status()
        print(status.model, status.client_count, status.wan_ip)
        for node in status.mesh_nodes:
            print("mesh:", node.name, node.model, node.ip)


asyncio.run(main())

Supported routers

Hardware code Model
RM1800 Xiaomi Router AX1800
RA82 Xiaomi Router AX3000T

Have a different Xiaomi router? Open an issue with the output of api/misystem/newstatus and we'll add it.

API overview

Method Description
async_login() Authenticate and cache the token
async_get_status() Aggregated MiWiFiStatus
async_get_clients() List of ClientDevice
async_get_dhcp_reservations() Current MAC→IP reservations
async_add_dhcp_reservation(mac, ip, name) Add/replace a reservation
async_remove_dhcp_reservation(mac) Remove a reservation
async_set_wifi_enabled(ifname, enabled) Toggle a radio (wl0=5G, wl1=2.4G)
async_reboot() Reboot the router

Development

uv venv && uv pip install -e ".[test]"
pytest
ruff check .

License

MIT © Hudson Brendon

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_xiaomi_miwifi-0.4.0.tar.gz (19.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_xiaomi_miwifi-0.4.0-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file python_xiaomi_miwifi-0.4.0.tar.gz.

File metadata

  • Download URL: python_xiaomi_miwifi-0.4.0.tar.gz
  • Upload date:
  • Size: 19.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for python_xiaomi_miwifi-0.4.0.tar.gz
Algorithm Hash digest
SHA256 7ece64cd8cb1bae010b8fa2d3d8970afaf8064e9fedf4515636164686e838a2c
MD5 c12fef0dc6657af59c8185bfb0b2ac68
BLAKE2b-256 683a24dc62daf2ff9ded142c11f3552e207a62c2b03b476b09ba77df196be18e

See more details on using hashes here.

File details

Details for the file python_xiaomi_miwifi-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for python_xiaomi_miwifi-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 78a66889afbc8b273a1ce95453564b8b07b558a14509ec43410993d329b25281
MD5 b7c68d5f6ea2bf9a375ed14284d29d1e
BLAKE2b-256 86779728331cf26c20eeff7c96a89a88d9a829c1df768826a7ecbbac75dd8ff9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page