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.3.0.tar.gz (16.9 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.3.0-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: python_xiaomi_miwifi-0.3.0.tar.gz
  • Upload date:
  • Size: 16.9 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.3.0.tar.gz
Algorithm Hash digest
SHA256 a1fd166500151d74177958a1aef878db368b2f5602b90a3b54a4f5fab3b724f4
MD5 eec33ffe16468e348ed669adf09c8af8
BLAKE2b-256 98e5eab1c1d6c5b626d60b9060846548d2ea77bc05a90df8d6975c1544a42bd9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_xiaomi_miwifi-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fdbecefdc66fdb1cc150e45e2d864a5b6833cf12528b7681fff375e9c9462387
MD5 0883d59fc754c20d8fd5fd1c0f2cec43
BLAKE2b-256 17a02ba8c5f70338a7a77828a096a5f4d264ae3c54d122a8635e95de00ab134d

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