Step 1: Pair in the Xiaomi Home app
Install the Xiaomi Home app, sign in, and add the device there. The HA docs are clear that you should use the Xiaomi Home app, not a vendor-specific one like the Roborock app. Note the account region you use. If the device was previously paired in another app, reset its Wi-Fi and pair again in Xiaomi Home, which generates a new token.
Step 2: Give it a stable address
Create a DHCP reservation for the device in your router so its IP never changes. If you use an IoT VLAN, decide now whether HA will live there too (see Step 5).
Step 3: Add it in Home Assistant
- Go to Settings > Devices & services > Add integration > Xiaomi Home (or accept it if it is shown as discovered).
- Enter your Xiaomi Home account email and password and choose the same server region as in the app. The HA docs say HA then retrieves the connection info and token, and connects to the device over your local network.
- Only use "Configure manually" if the account route fails. You will need the IP and the 32-character token (see Step 4).
On a computer in the same subnet:
Code: Select all
pip install python-miio
miiocli discover
Code: Select all
pip install micloud
miiocli cloud list
Then a quick test. Run miiocli --help to see the device types it supports and use the command group for your device type (the generic device group, for example, with --ip and --token options and an info command, as I understand it from the CLI help; check the help output on your version):
Code: Select all
miiocli --help
miiocli device --ip 192.168.20.15 --token YOUR_32_CHAR_TOKEN info
Step 5: VLANs and subnets
If HA and the device are on different subnets and the device does not respond (python-miio's error is "Unable to discover the device"), the documented fixes are:
- Same subnet for HA and the device. Simple, but you lose the segmentation.
- Dual-home the HA host (a second interface or VLAN interface in the IoT VLAN), with a local firewall on HA to restrict incoming connections from the IoT subnet, as python-miio advises.
- IP masquerading on the router's interface in the device's subnet, so requests appear to come from the same subnet. The docs call this the last resort, and it needs router access.
Step 6: Block the internet but keep it stable (REJECT not DROP)
Many people block IoT devices from the internet. For vacuums, the HA and python-miio docs say that silently dropping packets can make the device software hang until a watchdog restarts it, so you see intermittent unavailability. Use a firewall REJECT rule for the device's outbound traffic instead of DROP. For example on a Linux iptables router (adapt to OPNsense, pfSense, OpenWrt or your own firewall's wording):
Code: Select all
iptables -A FORWARD -s 192.168.20.15 -o wan0 -j REJECT
Security checklist
- Keep tokens, the Xiaomi account credentials and the HA config backups private.
- Use a strong unique password and two-step verification on your Xiaomi account if it is offered for your region.
- Isolate cameras, vacuums and gateways in an IoT VLAN.
- Valetudo and rooting are separate, more advanced topics. Read the Valetudo "Why not Valetudo?" page and follow its installation guide for your exact model first.
Question for the group: how have you segmented your Xiaomi devices from the rest of your network, and which of the three VLAN options (same subnet, dual-home, masquerade) worked for you?