How to Control the Xiaomi Mi Vacuum from HomeSeer

Back about a decade ago we had a Roomba I had received while doing the payperpost . The wife and I liked it and it did a pretty good job. It eventually died as electronics do and I wasn’t able to resurrect it. Eventually it went to the dump. Rather than replace it we just got a normal vacuum. The price of iRobot’s stuff is prohibitive and very much a luxury. A few weeks back I received an email from Gearbest and went to check it out. One of the things on sales was a Xiaomi Mi Vacuum. An extremely good deal so I went ahead and picked it up.

I finally received the vacuum a few days ago. Everything in Chinese, instructions, the voice (it has a built-in speaker), everything. It didn’t take me very long to figure out how to get it working though. The app lets you choose the language you are going to use so that made it a bit easier. I had not planned on doing a write-up of it so if I leave out steps or get something out of order, tough shit.

Since this thing could be controlled via Android remotely I knew that in theory I should be able to control it from Homeseer (my home automation software) with some work. I came across some python scripts and saw that you could control it via Home Assistant (another, free HA software). This “tutorial” is not the only way to do this and there are probably simpler ways to do it in less steps but you have to remember, I am not a coder at all and some of that shit just blows my mind when I look at it.

Anyway, here are the steps I took as best I can remember.

    1. First thing I did was to download the Mi Home app from the play store and set it up. I originally picked the U.S. server during set up but it really didn’t provide a lot of options. After a bit of reading I changed that to the mainland China server which gave me complete control over the vacuum.
    2. Set up Home Assistant. There are only a few things I can’t already control from Homeseer and I also wanted a way to integrate them all so HASS seemed to be the best way to do that. I already have a Raspberry Pi running NodeRED and MQTT for location tracking so figured I would be able to communicate between Homeseer and HASS that way.
    3. Follow the directions here to get control of the vacuum  from HASS. The hardest part is retrieving the access token for the vacuum. You need to be comfortable using the commandline and ADB in order to do so. If you have something other than an Android phone I don’t know any other way to do it. If you have a rooted phone (I don’t) the instructions seem to be even easier. Read through the entire page first before you start following their directions.
    4. The vacuum shows up as a switch on the main HASS page as below. 
    5. In Home Assistant’s configuration.yaml uncomment and set the http api password (near the top of the file).
    6. I seem to be having issues with MQTT and being able to control things back and forth from Homeseer to HASS without using eventghost so I chose to go with a more direct route. It doesn’t offer status updates back to Homeseer unfortunately but it does give me control and uses the HASS api which is why I set the password in step 5 and uses Curl. If you are running HS on a linux PC or raspberry pi Curl is already there. If you run under Windows then download it.  Here is my commandline:  c:\apps\curl.exe -X POST -H “x-ha-access: PASSWORD” http://192.168.86.65:8123/api/services/vacuum/turn_on or /turn_off
    7. In Homeseer create a virtual device called “vacuum” or whatever you want. I made sure to leave the voice control box checked on this.
    8. Create two events. One that triggers when the virtual device turns on and another when it turns off. For the action, choose Run Another Program or Process, browse to Curl and enter the command line parameters above. The turn_on parameter starts the vacuum in cleaning mode and turn_off directs it to go back to the dock.
    9. If you use Alexa, run discovery. Since I left the Voice Control box checked during my virtual device setup Alexa found it and now I can say “Alexa, turn on the vacuum” to start it!

 

I still have several things to do. During my initial setup of the app I set up a schedule for the floor to be cleaned twice a day. I need to remove that and create a scheduled event in Homeseer. This allows for local control and doesn’t depend on control from a server in mainland China. As a matter of fact it’s probably a good idea to block any IPs from China at your router if you have any sort of IOT devices.

I also need to figure out why I can’t just control my Homeseer devices via MQTT. I can send commands from Homeseer to Eventghost and NodeRED but don’t yet know how to trigger HASS switches and other devices via MQTT. Also any MQTT commands that Homeseer receives don’t seem to trigger devices. I have to intercept them in Eventghost and use a Homeseer event to get them working.

2 throughts on "How to Control the Xiaomi Mi Vacuum from HomeSeer"

  1. I had great success using MCSMQTT plugin with HomeSeer and connecting to Home Assistant. I used virtual switches to fire off events using MQTT from the MCSMQTT plugin. It also works great for getting back the status.

  2. Yeah, I’ve been using MCSMQTT since he released the plugin and have converted everything to use it now. Starting to play around with Sonoff switches as well running Tasmota. Working like a charm.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.