Xiaomi MiWiFi smart home integration, free and open source

Xiaomi routers (MiWiFi): presence of your devices, router health, Internet, locally.
Follow your Xiaomi router (MiWiFi firmware: AX, BE, Redmi and mesh series) from Gladys Assistant: who is at home, the health of the router and the state of your Internet connection. Everything stays on your local network: the integration talks to the web interface of the router, without the Xiaomi cloud.
Developed without the hardware: feedback welcome, on the issues of the project. This integration is not affiliated with Xiaomi.
Overview
- Presence: each device you choose (a phone, a laptop, a wired NAS) becomes a presence sensor, present while the router lists it as connected, on its Wi-Fi, on a cable or through a mesh node. Its IP address and its connection (Ethernet, Wi-Fi 2.4 GHz, Wi-Fi 5 GHz, guest Wi-Fi) come with it.
- Router: CPU load, memory, uptime, firmware version, number of connected devices.
- Internet: whether the WAN connection is up, the public IP address, the download and upload rates.
- Scenes: a device arrived or left, the first person home, everyone left, an unknown device connected, Internet down and restored.
- Command, disabled by default: rebooting the router.
- Widgets: the health of the router, and the devices at home.
Requirements
- A Xiaomi or Redmi router with the MiWiFi web interface (the page
http://192.168.31.1by default), in router mode. - Its administration password.
- Gladys Assistant 5.1 or later, on the same local network as the router.
Configuration
Install the integration (Integrations → Install from GitHub, address
https://github.com/guim31/gladys-miwifi), then fill in:
- Router address: the local IP address of the router, as in your browser (
192.168.31.1by default). - Administration password: the password of the web interface. It is stored by Gladys, and only a hash of it ever reaches the router.
- Login hash: leave Automatic. The router tells which one it expects; if a recent model refuses a correct password, choose SHA-256 (AX and BE series), and for an old one SHA-1 (older firmware).
- Refresh interval: how often the router is read (10, 15, 30 or 60 seconds).
- Departure delay (minutes): a device becomes away once the router has not listed it for this long (5 minutes by default): a phone asleep leaves the Wi-Fi for a few minutes without leaving home.
- Allow commands: lets the scene action and the widget button reboot the router. Off by default.
- Language of the names: the language of the feature names and of the texts sent by the integration (Gladys does not tell it yours).
Then click Test the connection: the report tells the model, the firmware, the Internet state and the number of connected devices.
Devices
Open the Discovery tab of the integration and add the devices you want.
The router
| Feature | Values |
|---|---|
| CPU load | % |
| Memory used | % |
| Uptime | hours |
| Firmware version | text |
| Internet connected | yes / no (the WAN connection of the router) |
| Public IP address | text (the address on the WAN side) |
| Download rate | Mbit/s, the current traffic of the WAN |
| Upload rate | Mbit/s |
| Connected devices | number of devices connected now (mesh aside) |
Network devices (presence)
The Discovery tab lists the devices the router has listed since the integration started (kept a week), under their name in the router. Each one has three features: Presence (present / away), IP address and Connection (Ethernet, Wi-Fi 2.4 GHz, Wi-Fi 5 GHz, guest Wi-Fi). The address and the connection keep their last value while the device is away. The mesh nodes are not listed.
Widgets
- Xiaomi router: CPU, memory, rates, connected devices, Internet and public address, uptime, firmware. When the commands are allowed, a Reboot button, with a confirmation; the setting Show the Reboot button hides it.
- Devices at home: the devices you follow, under the name you gave them in Gladys, present first, with their connection or the time since they left. Settings: Show all of them or the present ones only, Show the connection band.
Scene triggers
- Device arrived: a followed device connects again (optionally one device only). Variables: name, IP address, connection.
- Device left: a followed device has been away for the departure delay.
- First person home: a followed device arrives while none was present.
- Everyone left: the last followed device present has left. Variable: the last one.
- Unknown device connected: a device never seen before joins the network. Variables: MAC address, IP address, name in the router, connection.
- Internet down and Internet restored (with the outage duration in minutes).
No event fires at the first reading after a start: the integration learns the network as it is.
Scene actions
- Reboot the Xiaomi router: the network is cut for two to three minutes. Needs Allow commands.
Configuration actions
- Test the connection: logs in again and reads the router. A failure shows in red with its reason.
Scene examples
- Everyone left → turn the heating down and arm the alarm.
- First person home → turn on the hall light if the sun has set.
- Unknown device connected → send a message with its name and connection.
- Every Monday at 4:00 → Reboot the Xiaomi router.
Network use
One login, then three requests per reading (misystem/status, misystem/devicelist,
xqnetwork/wan_info) on the local web interface, in plain HTTP as your browser does. Nothing goes to
the Internet. The router keeps the session for a while; when it expires the integration logs in
again once. A refused password is tried again only every five minutes.
Troubleshooting
- Password refused: check it in the web interface of the router. A recent model (AX, BE) that refuses a correct password needs Login hash on SHA-256.
- The router does not answer: check the address, and that Gladys is on the same network.
- No MiWiFi web interface: the address is not the one of a Xiaomi router in router mode (a router in access point or repeater mode does not list the devices).
- A phone shows away while at home: raise the Departure delay (minutes); some phones leave the Wi-Fi when asleep.
- Detailed logs: set
LOG_LEVEL=debugon the container.
Limits
- Developed and tested against a simulated router built from the answers published by the hass-miwifi project, not on real hardware.
- Presence is what the router lists as connected: a device in deep sleep may disappear until it wakes up.
- The rates are the current traffic of the WAN as the router measures it, not a speed test.
- The guest Wi-Fi, the LED and the firmware updates are not handled. Only the main router is read: the devices behind its mesh nodes are seen, the nodes themselves are not followed.
Feedback
Open an issue on GitHub with your model, your firmware version and the report of Test the connection.
Configuration settings
These are the settings Xiaomi MiWiFi asks for in its configuration screen in Gladys.
| Setting | Type | Required | Description |
|---|---|---|---|
| Your Xiaomi router | section | No | The integration logs in to the local web interface of the router (MiWiFi), with the administration password. Nothing goes through the Xiaomi cloud. |
| Router address | string | Yes | Local IP address of the router, as in your browser. |
| Administration password | secret | Yes | The password of the router web interface (user admin). |
| Login hash | select | No | Automatic asks the router. Force SHA-256 if a recent model refuses a correct password. |
| Refresh interval | select | No | |
| Presence | section | No | Add the devices to follow (phones…) from the Discovery tab: each becomes a presence sensor. |
| Departure delay (minutes) | number | No | A device is away once unseen for this long: a sleeping phone leaves the Wi-Fi for a few minutes. |
| Commands | section | No | |
| Allow commands | boolean | No | Lets scenes and the router widget reboot the router. |
| Language of the names | select | No | Language of the feature names and the texts sent by the integration. |
How to install Xiaomi MiWiFi in Gladys
- In Gladys, open Integrations: Xiaomi MiWiFi appears in the catalog, next to the native integrations, with a community badge.
- Click Install. Gladys pulls the Docker image (
ghcr.io/guim31/gladys-miwifi:1.0.0), starts it in a sandbox isolated from the core, and generates the integration's interface (devices, discovery and configuration). - Open the Configuration screen of the integration, fill in the settings, and save.
- You can also install it directly from its repository URL: https://github.com/guim31/gladys-miwifi.
Xiaomi MiWiFi requires Gladys >=5.1.0. The catalog inside Gladys refreshes every hour, so a new version becomes available at most one hour after its release.
Not running Gladys yet? It is free and open source: follow the installation guide to get started.
About external integrations
Xiaomi MiWiFi is an external integration: a community integration packaged as a Docker container and published on GitHub, that Gladys installs in one click and runs in a sandbox isolated from its core. It is published and maintained by guim31, not by the Gladys core team.
- Browse all integrations, native and community
- Build and publish your own external integration
- Source code on GitHub — source of this documentation