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.1.0.tar.gz (12.2 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.1.0-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: python_xiaomi_miwifi-0.1.0.tar.gz
  • Upload date:
  • Size: 12.2 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.1.0.tar.gz
Algorithm Hash digest
SHA256 057ba0248cf93d20afd5450c0c466859be2bb3e0747746cd48e411fbc656572f
MD5 ad7d164d90abf7c8dc699c0e93c7804c
BLAKE2b-256 448476ab51442211705dc76e1ecb1a37d2eb88a83f7445aa6b7658b03a230462

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_xiaomi_miwifi-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 410e548e700c31727dc4f7b1764ac52ca27ae34a06981a94f951efa7b87145e7
MD5 c1e15d7fdfe915b3dedf641c1507e5e6
BLAKE2b-256 408bc9ce733e0631bc6ac7c7b14bffbcf51e243f871e7a7072be5c6741dc4272

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