Previously, we integrated the Ecovacs robot vacuum cleaners, blink cameras as well as connected objects Smart Life/Tuya in Home Assistant. Today, we continue our momentum by integrating Xiaomi and Roborock vacuum cleaners into Home Assistant. Brands widely used by fans of home automation and whose reputation is second to none.
You can also find the Roborock S4 tests, S5 Max, S6 and S7+ in our lab'. Convincing robots acclaimed by their users that we particularly appreciate and that we rank among the best robot vacuum cleaners on the market!
« Alexa, ask Nestor to clean the kitchen. "
Currently the following services are supported:
- start : Start the robot vacuum
- pause : Pause the robot vacuum
- stop : Stop the robot vacuum
- return_to_base : The robot vacuum cleaner returns to its charging base
- locate : Used to locate the vacuum cleaner
- clean_spot : Send the vacuum robot to clean a specific corner of the housing
- set_fan_speed : Allows you to control the suction speed (Silent, Standard, Medium, Turbo)
- remote_control_ * : Control the vacuum cleaner with the virtual keys
- xiaomi_clean_zone : Allows you to send the robot vacuum cleaner to a specific room
Set up a Xiaomi Roborock robot in Home Assistant
For the proper functioning of the integration it will be necessary get the token (token) which will allow your vacuum cleaner to interact with the API as well as set your IP address from your ISP box or router.
Static IP for Xiaomi robot vacuum cleaner
To set the IP of your device, you just have to go to the interface of your internet box or router. For my part, it will be since livebox / to access my Orange internet box.
There you have it, your vacuum cleaner has a fixed IP address. If you restart your internet box, Home Assistant will be able to find your robot vacuum easily.
Easily recover a Xiaomi Mi Home token
Download the latest version of the application “Get Mi Home Devices Token App” on Github for Windows or macOS.
Install the app : on Windows as on MacOS, an authorization is necessary. Don't worry, the code is public and available on Github, it has been validated by the community.
Enter your account credentials : username (login) and password (password).
Select token that you want to recover.
You can now use your Xiaomi Home token in a third-party integration or application. Note, however, that your device remains tied to the cloud and will not work locally.
Ingredients
Instructions
Download the latest version of the application “Get Mi Home Devices Token App” on Github for Windows or macOS.
Install the app : on Windows as on MacOS, an authorization is necessary. Don't worry, the code is public and available on Github, it has been validated by the community.
Enter your account credentials : username (login) and password (password).
Select token that you want to recover.
You can now use your Xiaomi Home token in a third-party integration or application. Note, however, that your device remains tied to the cloud and will not work locally.
Old methods
If you prefer alternative methods, you can always retrieve the token of a Xiaomi or Roborock vacuum robot from the Xiaomi Home application. The procedure is different for an iOS device and an Android device.
Retrieve the token from an Android device:
- Add (if it is not already done) your vacuum cleaner on the application Xiaomi Home
- Uninstall the Xiaomi Home app (Yes Yes..)
- From your phone, download Aptoide
- From Aptoide, download the Mi Home app 5.4.54 (Secure, old official version of Xiaomi Home)
- Open the Mi Home app freshly installed then wait a few seconds for your devices to appear
- Once most of your devices have appeared you can close the application
- Open the application "File manager" and look for the file « SmartHome »
- This folder will contain log files, open the most recent file (opening it from a computer will be much easier to find your computer's token)
- Find the name of your vacuum cleaner, once found, there will be a little before a line that looks like: {token: XXXXXXXXXXXXXXX}
- Copy this token, we need him for the rest of the tutorial
Retrieve the token from an iOS device:
- Add (if it is not already done) your vacuum cleaner on the application Xiaomi Home
- On a PC or Mac with iTunes installed, you need to backup iPhone.
- install iBackupViewer, open it and open your backup
- Open the "raw data" module (tree-shaped logo)
- Access to com.xiaomi.mihome
- Look for a file that looks like XXXXXXX_mihome.sqlite in the file Documents
- Save this file to your computer
- install DB Browser for SQLite (The portable version is sufficient)
- Open DB Browser for SQLite, click on "Open a database" then go to select the previously downloaded file (XXXXXXXX_mihome.sqlite)
- In the tab "Browse data" scroll through the columns to the last column (ZTOKEN)
- Click on it, you should see the token we want to use
- Your token is encrypted, we will decrypt it from a free site
- The right column should look like this:
Key (required): 00000000000000000000000000000000
Configuration in Home Assistant
The most complicated is over, you can now integrate your vacuum cleaner into Home Assistant.
For integrate your vacuum cleaner into Home Assistant, add this in your file configuration.yaml :
vacuum:
- platform: xiaomi_miio
host: 192.168.XX
token: Your_token
name: Nestor
Once the file is saved, restart your Home Assistant server.
The variables of the xiaomi_miio integration
- host : The IP address of your vacuum cleaner
- token : The API token we retrieved earlier
- name : The name you want to assign to your robot vacuum cleaner (Here, Nestor 🙂)
The attributes available for Xiaomi and Roborock robot vacuums
Your vacuum cleaner informs us on many points:
- battery_icon : The battery% of your vacuum cleaner
- cleaned_area : The number of m² cleaned
- fan_speed : The suction speed of the vacuum cleaner
- fan_speed_list : The list of suction speeds available for your vacuum cleaner
But the integration xiaomi_miio de Home Assistant allows us to know more:
- cleaning_time : The time taken by the vacuum cleaner to clean
- main_brush_left : Hours remaining until a main brush change is required
- side_brush_left : Hours remaining until a side brush change is required
- filter_left : Hours remaining until a filter change is required
- sensor_dirty_left : Hours remaining before cleaning the sensors
- cleaning_count : Total number of cleaning cycles
- total_cleaned_area : Total area cleaned in m²
- total_cleaning_time : Total cleaning time in minutes
- do_not_disturb : Activation / Deactivation of do not disturb mode
- clean_start : The last date / time the vacuum cleaner started cleaning
- clean_end : The last date / time the vacuum cleaner finished cleaning
Possible script for the filters and brushes of your Xiaomi robot vacuum cleaner
The vacuum cleaner stores attributes like main_brush_left ou filter_left which allow to know the number of hours remaining before changing the component in question. However, once the change is made the attribute does not automatically reset. I therefore propose a scenario allowing you to reset the value once the change has been made:
reset_brosse_principal_nestor:
alias: "Reset the time of the main brush of Nestor"
sequence:
- service: vacuum.send_Command
date:
entity_id: vacuum.nestor
command: reset_consumable
params: ['main_brush_work_time']
Available settings:
- ['main_brush_work_time']
- ['side_brush_work_time']
- ['filter_work_time']
- ['sensor_dirty_time']
This is a script and not an automation.
You can call your script from a virtual button on the dashboard or add it to a self-regulating automation techniques.
Retrieval of cleaning details
In order to target a targeted room or area we need coordinates.
Using the FLOLEVAC application
- Download Flolevac
- Log in with your Xiaomi credentials (Tested by Google Play Protect)
- Open the map (Make sure you are on your home network)
- Select "Zone cleaning" et draw a square around the area that you want to clean
- Long press " Cleaning " and the coordinates of the area will be copied to your clipboard
Automation with coordinates
I offer you an automation that allows you to launch a cleaning of a specific area
- alias: Kitchen cleaning
trigger:
- event:start
platform: homeassistant
condition: [] action:
- service: xiaomi_miio.vacuum_clean_zone
data_template:
entity_id: vacuum.nestor
repeats: 1
zone: [[XXXXX, XXXXX, XXXXX, XXXXX]
- entity_id : replace it with the name of your vacuum cleaner
- repeats : here it will clean this area once (you can put the number of repetitions you want)
- areas : the area (s) to be cleaned
Example with two zones:
zone: [[30914,26007,35514,28807], [20232,22496,26032,26496]]
Lovelace card for your Xiaomi or Roborock vacuum cleaner
I also share with you a additional integration interesting that allows you to start cleaning a specific part using a static map, as in the Mi Home app. In addition, vYou can define a list of zones and choose which ones to clean.
Do not hesitate to share in comments or via the facebook group your scenarios that help you on a daily basis. 🙂
Very interesting, thank you… but will you publish the guide for the “Xiaomi Mijia Mop P” soon?
Hello, it will be available soon 😉
(The procedure remains almost the same, you just have to manually add the files in custom_components 🙂)
good evening, unfortunately the site to decrypt the token is not free ... another solution? Thank you in advance 😉
i am on ios so i use an android emulator under my mac
super simple integration
because the map is not displayed in FloleVac
Thank you for the feedback, I will look for a second solution because floleVac does indeed encounter problems for the creation of cards with multi-card vacuum cleaners
Hello, indeed this is an interesting solution that also works 🙂 Thank you for your feedback
Hello Alexians!
Are you sure Mi Home is still available on the Aptoid store? Unable to find it through the search ^^
Great article, can't wait to continue once the token has been collected 🙂
Thank you!
Great tutorial! New in Home Assistant, I enjoy its beauty, its logic and its power.
For those looking in the comments to retrieve the token from their device as simply as possible, here is the simplest one I found:
To recover my roborock token, I installed version 5.4.49 of mihome (available on apk mirror), then after having configured my account on "Europe", I went to see the log file in / sdcard /SmartHome / logs / plug_DeviceManager / .log. Towards the end of the file, we have a line like this:
"Did": "DEVICE_ID", "token": "MONTOKEN", "longitude": "0.00000000 ″," latitude ":" 0.00000000 ″, "name": "Robot vacuum"
And there magic, we have the token in clear!
Then all you have to do is update mihome.
Recover mi home vevs it provides the tokens and allows you to put any device on any server.
Hello, I used this link for my Xiaomi Mijia Mop P (viomi.vacuum.v8): https://github.com/rytilahti/python-miio/blob/master/miio/vacuum_cli.py#L58
But I failed to integrate it (am a blue / newbie).
Maybe pay attention to the v7 or v8 version because v8 would be a Europe model?
Best regards and congratulations for your site and videos
Patrick
Sorry, little error in the link, here is the correct link: https://github.com/nqkdev/home-assistant-vacuum-styj02ym
And very good news, it works with those who have the Europe version viomi.vacuum.v8 (v.3.5.3_0017)
For yourself
Patrick
Great ! 🙂 Thank you for this feedback ...
Hello,
Does this token recovery procedure also apply to the new Roborock S6 MaxV via iOS or iMac device?
I understood that there was a difference between the Mi Home app and Roborock. Which one used for an optimal integration in Home Assistant?
Thank you for your help.
It's with Xiaomi Home and the S6 MaxV is currently only available on the Roborock app it seems to me.
I managed to retrieve the token.
However, I have an error in HA. I thought it was because I didn't have xiaomi_miio installed.
So I went to add it in the integration but I am asked to enter the IP and the token of a Xiaomi Gateway ... which I do not have: /
Any idea what I should do please?
Still running in December 2020! Perfect thank you very much !
Thank you for the feedback ! 🙂
Hello, the Roborock S6 maxV is now supported under Mi Home (but not the transmission of its camera).
And to retrieve the tokens of all your Xiaomi products (regardless of the server on which you have saved them), this python script is just impeccable:
https://github.com/PiotrMachowski/Xiaomi-cloud-tokens-extractor
Hello,
For information there is a tool to retrieve the token directly from the computer without all the manipulations:
https://github.com/Maxmudjon/Get_MiHome_devices_token/releases/tag/1.0.2m
it worked for me
Hello,
It's great ! Thank you for the information ! 🙂
Have a good day
Hello, I am testing with the roborock S7, cannot add it to HomeAssistant
It does not appear in my board, yet I did all the steps well 🙁 Help! Thank you 🙂
Hello,
It just came out, it usually takes a little while for Xiaomi Home to support them ... 🙂
Hello. I want to try but I have the d9. Do I have to do something else knowing it's a multi-card?
For my part, he should install himself on Google home according to the other forums but after connecting to the xiaomi site, he returns to the Google home app and says to me: couldnbt reach .. Mi home… ”
Thanks to you if you have the answer
Hello,
Are you just talking about Google Home or also Home Assistant?
For Google, there are some concerns that I know ... Check that you are on a European Xiaomi Home server, it could come from there. 🙂
Good luck 😉
Hi
I am using the Roborock app because the Mi app is not suitable for me. Does the tutorial for HA work if I sniff network data to find the token in the Http header?
Hello,
I haven't retested recently, but it didn't work with the Roborock app during the tutorial… 😉
Hello,
I integrated my Roborock S5 vacuum cleaner directly with the “Xiaomi Miio” integration offered via the Home Assistant interface, by connecting to the Xiaomi cloud via my username / password.
What is the difference with the method described in this tutorial? With your method, do we do without the Xiaomi cloud and we interact directly locally with the vacuum cleaner?
Thank you in advance,
Yann
Hello Yann,
It is simply a tutorial which dates from the time when integration did not exist… This one also uses the cloud so we can say that it is obsolete. 😉
Good evening 🙂
Hello,
Can we turn into a skill alexa ? I do not have smart home, is there an alternative?
thanks in advance.
Hi,
This tutorial is for Home Assistant, a home automation software that works locally on your own system… If you are simply looking for a skill Alexa, several are available depending on the brand of your robot: Xiaomi Home, Roborock also, Dreamer ou Roidmi also…
Good evening 🙂