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.5.0.tar.gz (22.7 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.5.0-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: python_xiaomi_miwifi-0.5.0.tar.gz
  • Upload date:
  • Size: 22.7 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.5.0.tar.gz
Algorithm Hash digest
SHA256 12e25c482242b760a7403476fba82cd3062c9c21773384e9ab2b7b9c90fd552e
MD5 2a94eac6b245d28beabe9e0e8f799250
BLAKE2b-256 0734108cc40e59e67d0b0ae09b4d7257d3fef8bb8bbb229da20e6ba4071f46ae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_xiaomi_miwifi-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fa331c684ca606ce39c0975916541780843fbca9e467e152b7255f3bb150b0e3
MD5 73e705dddf04e6445b7450330bff4ad4
BLAKE2b-256 c72f17e5d58eac2c2e06a7a8301c815424e2674a276200c341b40bc173dc4eeb

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