The Xiaomi Robot Vacuum, Home Assistant, and Alexa

**This post will cover setting the Xiaomi Mi Robot Vacuum up to work with Home Assistant. If you don’t use Home Assistant and want to control your vacuum with only your Alexa device, go here.**

I recently splurged and got myself a robot vacuum and I think it’s been the best purchase I’ve made in my adult life. I work full time and go to school, so the fewer chores I have to do, the better. Now, I can just dust the counters and flat surfaces off onto the floor and when I get back from work I come home to a cleaner apartment. While this purchase cost more than the rest of my gadgets combined, that’s not saying too much since I am using my $200 Smart-Home set up. It is arguably the most useful of any of my Smart-Home devices.

There are so many Robo-vacuums available right now, that it was hard sifting through the different options. I had to do a fair amount of homework searching for the right one and I think I found it in the Xiaomi Mi Robot Vacuum. I have been very impressed with the Xiaomi brand since I started using their Smart-Home Gateway and Sensors; my experience with their vacuum is no different. It is user friendly, it feels like a solid piece of technology, it looks sleek and clean, and it works like a champ! Most importantly, it is compatible with Home Assistant, an open source Home Automation platform that I use.

This guide includes:

  1. Unboxing the Xiaomi Mi Robot Vacuum
  2. Setting the vacuum up with the Mi Home App
  3. Making the vacuum speak English, and changing the vacuum’s name
  4. Getting the vacuum’s Access Token using Windows and an Android device
  5. Integrating the Xiaomi Vacuum component in Home Assistant
  6. Adding the vacuum to Home Assistant’s front end & configuring it to work with Alexa
  7. Extra Parts and Accessories

Notice:

This post has been marked as a legacy post and has been flagged to be updated.

If you would like to receive updates from Smart Home Hobby, please subscribe below.


Unboxing the Xiaomi Mi Robot Vacuum

Unboxing the vacuum is easy. It comes ready to use, you’ll just want to charge it up a little more before attempting a full vacuum. There was enough juice in it to mess around with it for a little bit first, though, which was fun.

The box contains:

  • The Xiaomi Mi Robot Vacuum
  • The Charging Station
  • A Brush Cleaner
  • Set up Instructions

Setting Up the Vaccuum

  • The first thing you’ll want to do, is get the vacuum connected using the Mi Home App.
    • The current app does not make the Access Token available to us.
    • You will need to download an older version of the app.
    • Mi Home 5.0.0 is what I used, and can be found here.
      • Use the Mainland China servers
  • Log in to the app or create a new account.
  • The app may discover the vacuum on it’s own, if not, select the “+” in the top right corner, select the vacuum from the options, and follow the instructions.

Screenshot_2018-03-18-13-22-23

Now that your Xiaomi Mi Robot Vacuum is set up, you can use it from the app. Click on the Vacuum from your app and agree to the terms provided. The blue area will populate with a map as the vacuum uses its IR sensor to scan the area.

The bottom of the screen has 3 buttons:

    • Dock- Will send the vacuum back to the dock to charge
    • Clean – Will begin the cleaning process
    • Speed- You can cycle through 4 different settings
      • Quiet
      • Blanced
      • Turbo
      • Full Speed

  • When doing a cleaning, you can follow along in the app.
  • The vacuum will create a map and show you what has been cleaned.
    • It will create a new map each time it runs and show you where it has cleaned.
  • This vacuum requires a 4″ clearance to fit underneath any furniture.

Make the Vacuum Speak English & Change its Name

Now, it’s likely that the vacuum has been speaking Chinese to you throughout the setup process. You can easily change the vacuum’s voice pack to English.

  • From the vacuum screen, click the settings icon in the top right corner
  • Choose “Vacuum Settings”
  • Select “Voice Pack”
    • On the bottom of this page you should be able to choose “English: female voice”
  • Go back to the “Settings” page. While you’re here in the settings, it would be a good time to change the name of the vacuum.
    • Choose “General Settings”
    • Select, “Rename.”

Get the Vacuum’s Access Token, Using Windows and An Android device

Since my last post, my computer died. Up until this point I had been using an old MacBook that I’ve had forever. I’ve switched over to Windows, and it turns out to have been good timing. What seems to be the easiest method for grabbing the vacuum’s token is done with Windows and an android device. Other methods can be found on the Xiaomi Mi Robot Vacuum’s Home Assistant component page.

  • The first step in accessing the vacuum’s token is to download MiTookKit.zip.

1

  • Unzip this file and open MiToolKit.

3

  • Once opened, you’ll notice it is in German, you can click on the little flag at the bottom to switch it to English.
  • Click the Extract Token button.

13

  • There are a couple of requirements you’ll notice that need to be fulfilled before you can use this application.
    • First, activate USB debugging on your Android device.
    • Second, make sure you’ve got Java installed.
    • Lastly, connect your Android to your computer & open the Mi Home app.

5

  • Now, extract the token from your Android.
    • Your token MUST have numbers and letters. If it is only numbers, it will not work. To get a new token, just delete the vacuum from the app and re-add it in.
    • I used the Mainland China server in the Mi Home App
    • If you are only getting the IP address for the vacuum, you are using an updated version of the app. Make sure to use the 5.0.0 version.
    • Don’t set a password for the backup being created
    • You can see the application pulled all of the tokens from my other Xiaomi and Yeelight devices.

Connect the Xiaomi Vacuum to Home Assistant

**Be Aware, Home Assistant 0.62 broke the Miio platform used for the vacuum, which was fixed in version 63.3. Make sure you are using an appropriate version of Home assistant. I used 65.5 when I made this post.**

So, you’ve snagged your token… now what? Start by opening your configuration.yaml file.

code1

https://gist.github.com/smarthomehobby/0628adfd10779536f9058044f01b3146

  • Add this to your configuration file and save.
    • The name is optional.
  • Be sure to check your configuration in the configuration tab before restarting Home Assistant.

Vacuum State

  • Now you should be able to see your Xiaomi Mi Robot Vacuum in the States page.
    • Notice mine says “vacuum.robovac” based on the name I used in my configuration.
      • By default, this would be “vacuum.xiaomi_vacuum_cleaner”

Adding the Vacuum to the Home Assistant Front End

Vacuum in status

  • You can add your vacuum to your front end by adding “vacuum.YOUR_ROBOT_NAME” to any of your groups.
  • You can use any of the attributes on the “States” page as individual sensors. You can do this with a sensor template added to your sensors.yaml, like this:

https://gist.github.com/smarthomehobby/7807b99cf473d61cfa71607da033be61

  • I started going this route, then realized if you click on the vacuum component, it’ll show you all the good stuff and give you some extra control beyond the on/off switch.

robo vac card

  • This card gives you Start/Pause, Stop, Spot Clean, Locate Vacuum, and Return Home
  • You can also control the fan speed from here
  • The ‘do not disturb’ times, are ones that I set from within the Xiaomi Mi Home app
  • Main brush left, side brush left, and filter left refer to how much longer (in cleaning hours) before that part needs to be replaced
    • Be aware, the Mi Home app also has a countdown to when it is necessary to clean the sensors, this is not included here, but should be considered in order to maintain your vacuum.
  • Now you’re all set… right? NO! Well, not me anyway. I wanted to also be able to control the vacuum through Alexa. Unfortunately, adding the vacuum to the rest of the switches did not work because it is a vacuum component and not a switch component. So I had to make a switch that Alexa CAN control using the switch template.
  • Open your configuration.yaml or switches.yaml; wherever you keep your switch components.

code2

https://gist.github.com/smarthomehobby/f0665d79f898adc5325c25d7d7816809

  • Add this switch to your configuration, be sure to replace “robovac” with the name of your vacuum.
  • Now add “switch.vacuum” to the rest of your Alexa accessible entities.
  • Make Alexa find your devices, and you should see the new vacuum switch!
    • The on command will start the cleanup and off will return it to the dock.
  • One more addition I did for fun was a script to find the vacuum.

code3

https://gist.github.com/smarthomehobby/9224f46833e9a6cc2551ba5e3da19d4e

  • Add “script.find_vacuum” to the rest of your Alexa accessible entities.
    • After it’s added, you can create an Alexa Routine inside the Alexa app to find the vacuum!

Screenshot_20180320-195754.png

Screenshot_20180320-200145.png

We’ve covered how to connect the Xiaomi Mi Robot Vacuum to the (older version) Mi Home app, extract the Token from the app, and add the Xiaomi Vacuum to Home assistant. You can now also control the vacuum through the app, Home Assistant, and Alexa (by using a switch template). Lastly, you can also find the vacuum by asking Alexa, “where’s the vacuum?” I’ve really enjoyed my short time with the Xiaomi Mi Robot Vacuum and think you will too. My Smart-Home feels so much smarter now! If these guides have been helpful to you, please share them! If you have any questions, please reach out to me in the comments. Thank you for visiting!

Extra Parts & Accessories

The vacuum’s consumable pieces (main brush, side brush, and filters) can be purchased in different kits or individually. The only extra accessory for the vacuum that doesn’t come with the vacuum is the Mi Invisible Wall. Some options are available on Amazon, some Gearbest, and some on both. The vacuum itself is also available from both sellers. I’ve provided some links below.

Gearbest Xiaomi Mi Robot Vacuum

Xiaomi Mi Robot Vacuum

Amazon GearBest

Gearbest 5 piece Mi Robot Vacuum Smart Cleaner Accessories

5 piece Mi Robot Vacuum Smart Cleaner Accessories

GearBest

Original accessories For XIAOMI MI Robot Vacuum

Gearbest Robotic Vacuum Cleaner Filter for Xiaomi

Robotic Vacuum Cleaner Filter for Xiaomi (Individual)

Amazon GearBest

HEPA Filter accessories For XIAOMI MI Robot Vacuum cleaner (2 Pack)

Gearbest Robotic Vacuum Cleaner Rolling Brush for Xiaomi

Robotic Vacuum Cleaner Rolling Brush for Xiaomi

Amazon GearBest

Gearbest Robotic Vacuum Cleaner Side Brushes for Xiaomi

Robotic Vacuum Cleaner Side Brushes for Xiaomi

GearBest

Gearbest Robotic Vacuum Cleaner Rolling Brush Cover for Xiaomi

Robotic Vacuum Cleaner Rolling Brush Cover for Xiaomi

Gearbest Mi Invisible Wall for Xiaomi

Mi Invisible Wall for Xiaomi

BLENDX Boundary Markers for Neato Botvac Series Neato and Shark ION Robot Vacuum, Alternative accessories magnetic strip tape for xiaomi vacuum, 13 Feet

16 thoughts on “The Xiaomi Robot Vacuum, Home Assistant, and Alexa

  • August 19, 2018 at 2:04 pm
    Permalink

    Great write up from start to finish, it greatly helped me to set mine up – thanks, I wish more Home Assistant “walk through”s were this good.

    Reply
    • August 20, 2018 at 7:01 am
      Permalink

      Thank you so much! What a great compliment! I’ve got more to share regarding the Xiaomi Vacuum. I’ve worked out how to send it to individual rooms within Home Assistant. It might take some time for me to get the walkthrough put together, but in the meantime be sure to download the FloleVac app to control the vacuum. It is 1000 times better than using the Xiaomi app. https://xiaomi.flole.de

      Reply
  • September 13, 2018 at 4:09 pm
    Permalink

    Thank you for a great write up. Can I upgrade to the latest version of Mi Home app after getting the token with the old version 5.0.0? Also, can I change back to US server after that?

    Reply
    • September 13, 2018 at 4:16 pm
      Permalink

      You can upgrade the app if you want, but if you ever need to regenerate a token, you will have to downgrade the app again. I don’t think the vacuum works on the US servers. I, personally, hate the Mi Home App. I highly recommend using this app for the vacuum instead https://xiaomi.flole.de/

      Reply
  • November 3, 2018 at 5:25 am
    Permalink

    Thank you for your detailed guide! Unfortunately for me the switch doesn’t work. The vacuum (2nd gen – roborock) works properly in HA. I created the switch adding your lines in the yaml and checked with HA, but when I try to activate it nothing happens both in HA and Alexa (I can see the switch).

    The name of the device is “Spazzolone” I used vacuum.spazzolone in the config. Any idea?

    Reply
    • November 3, 2018 at 7:08 am
      Permalink

      There was a breaking change to this set up in HA version 0.77.3 where they changed all of the vacuums to work similarly. https://www.home-assistant.io/blog/2018/08/29/release-77/#read-more

      Update Xiaomi Vacuum to new StateVacuumDevice changed some services: turn_on -> start, turn_off -> return_to_dock, toggle has been removed. States ‘on’ and ‘off’ will also no longer be used. (@cnrd – #15643) (breaking change)

      Try replacing “turn_on” with “start” and “turn_off” with “return_to_dock”

      I haven’t had a chance to update mine yet, but this should work. Please report back if this fixes your issue, if you don’t mind.

      Reply
  • November 4, 2018 at 10:11 am
    Permalink

    Thank you for your quick reply Alex! I replaced as you said, and now the “start” turns on the vacuum with Alexa!! Unfortunately with “return_to_dock” the vacuum is not going back to the dock but at least I could start up the Vacuum! I’ll investigate a little bit further on the return to the dock issue

    Reply
  • November 8, 2018 at 6:23 am
    Permalink

    hey there i got a simple question about the robot, how does it work with cables? does it suck them up or ignor them? is there a good way to hide cables who are generally on the ground?

    Reply
    • November 8, 2018 at 2:04 pm
      Permalink

      The cables may get caught up in the vacuum. I don’t do scheduled vacuuming because of that. Typically, I’ll go around the house and move stuff out of the way before I leave for somewhere and vacuum while I’m gone. You can use different things for cable management, it just depends where you’re looking to hide them.

      Reply
  • November 9, 2018 at 2:14 pm
    Permalink

    In the end I found out that with “return_to_base” works instead of declared “return_to_dock”!

    Reply
      • April 26, 2019 at 6:56 am
        Permalink

        Somehow very frustrating…
        I build a switch as above written:

        – platform: template
        switches:
        vacuum:
        friendly_name: Staubsauger
        value_template: “{{ is_state(‘vacuum.Staubsauger’, ‘on’) }}”
        turn_on:
        service: vacuum.start
        data:
        entity_id: vacuum.Staubsauger
        turn_off:
        service: vacuum.return_to_base
        data:
        entity_id: vacuum.Staubsauger

        The good thing: Vacuum is starting his job when I’m clicking the switch but then the switch immediately turns back to “off” after the vacuum starts.

        Do you know how to fix this?

        Reply
  • January 5, 2019 at 9:51 am
    Permalink

    Thank you but i got some Problems in configuration.yaml

    can anyone post the complete configuration.yaml so i can find whats wrong

    Reply
  • February 12, 2019 at 5:28 pm
    Permalink

    Hi,
    I have some troubles to make the switch command the vacuum. Could you post the code that you have and that is working with Roborock?

    Reply

Leave a Reply