Xiaomi

system: device provider: vacuum/xiaomi introduced in v0.1 internalPull

Plugin provides control of Xiaomi vacuum (gen 1 and 2).

Vacuum tends to ignore about 20% status requests, so you might see update in the UI with some delay. So far provider uses 1 second delay between sending the command and requesting an update.

To begin using this plugin you need to obtain a token from the device. There’re multiple options available, unfortunately all of them are kinda complicated. Since the last few versions vacuum changes its token after paring with the app and no longer advertises it. Below are possible ways to get it.

iOS app

  1. Connect vacuum through the Mi-Home app
  2. Create an unencrypted backup of your phone using iTunes
  3. Install iBackup Viewer
  4. Go to com.xiaomi.mihome
  5. Extract file 123456789_mihome.sqlite
  6. Install SQLite Browser and load your file
  7. Run the following query SELECT ZTOKEN FROM ZDEVICE WHERE ZMODEL LIKE "%vacuum%" and copy 32-digit token
  8. Run the following command in your terminal

    echo '0: <YOUR HEXADECIMAL STRING>' | xxd -r -p | openssl enc -d -aes-128-ecb -nopad -nosalt -K 00000000000000000000000000000000

Android app

WARN Latest app version is no longer storing token on the device and instead uses calls to Xiaomi Cloud.

  1. Downgrade your Mi-Home app to 5.0.0 version
  2. Enable developer mode and USB debugging on your phone
  3. Install ADB tools
  4. Create a backup of the application adb backup -noapk com.xiaomi.smarthome -f backup.ab
  5. Confirm backup on your phone WITHOUT password
  6. Install ADB Backup Extractor
  7. Extract everything from the backup java(.exe) -jar abe.jar unpack backup.ab backup.tar, extract .tar archive
  8. Install SQLite Browser and load your file
  9. Run the following query select token from devicerecord where name like "%Vacuum%"

Custom firmware

This method requires installing DustCloud custom firmware to obtain the root. Please refer to the official documentation for the details.

It’s much easier to install through flasher.py. If you have the latest firmware installed on your vacuum, do the factory reset first.

After DustCloud is installed, ssh into the device and get your token:

printf $(cat /mnt/data/miio/device.token) | xxd -p

Configuration options

Param Required Type Default Description
ip yes ipv4 IP address of the vacuum
key yes string Vacuum encryption key

Supported properties

Property Type Description
vac_status status Status of the vacuum
battery_level percent Current battery level
fan_speed percent Current fan speed
area float Last cleaned area (m2/ft2)
duration float Time of the last cleaning (in seconds)

Vacuum statuses

  • unknown - Unknown status
  • cleaning - Vacuum is in a cleaning state
  • paused - Cleaning paused
  • docked - Vacuum is at the dock
  • charging - Vacuum is charging and battery is lower than 80%, commands are disabled on UI. They will still work through the triggers/scripts.
  • full - Vacuum dust bag is full

Supported commands

Command Input Description
on Turns the device on
off Turns the device off
pause Pauses the device
dock Send vacuum to the dock station
find-me Makes vacuum to play Find Me sound
set-fan-speed percent Sets the fan speed

Example

system: device
provider: vacuum/xiaomi
name: vacuum
ip: 192.168.0.31
key: 476d424348304f414776726d3330786e