Automating and integrating a Xiaomi Mi Robot Vacuum into Home-Assistant (part 1)

Xiaomi Mi Robot Vacuum

Recently we borrowed a Xiaomi Robot Vacuum as the owner was returning to his home country for a month or so due to Covid-19. We brought it into our home and began to set it up. It worked surprisingly well. I was sceptical to begin with, but we have wooden floors and this thing is relatively resiliant at getting into the gaps in the room and not getting caught up on the rugs or cables etc.

You can find it here on Amazon (affiliate link – won’t cost you anything):

https://amzn.to/2yPKNNj

Alternatively you can find it here on Aliexpress: Xiaomi Mi Robot Vacuum

AliExpress.com  – Original Xiaomi Smart Robot Vacuum Cleaner 1st Gen 

 

I decided I was going to integrate this into home-assistant. I went to the integrations page and decided to go through the checklist, which aside from a configuration.yaml entry also meant extracting a token from the machine itself.

Firstly, I needed to download an old version of Mi Home – it’s version v5.4.49 and you can find it here: https://www.apkmirror.com/apk/xiaomi-inc/mihome/mihome-5-4-49-release/

(I suggest to switch off auto-update immediately on this one).

With this installed on my android phone, I needed to reset the wifi on the vacuum. Unfortunately, it’s not able to work without this initial wifi set up so you’ll need to start again if you already have one.

I held down the two buttons on the unit for 3 seconds and then set it up as a new vacuum in the instructions. Once it was set up and “claimed” i.e. part of my “home” on the app, i then browsed through my android phone using a file explorer and found the following file (i’ll show you the location but for you it could be different):

PHONE\Internal shared storage\SmartHome\logs\plug_DeviceManager\2020-04-09.txt

 

I opened this text file, and searched for token, and sure enough it was sat there in plain text smiling at me.

SmartHome 400797:[DEBUG]-04-09 17:50:55.730 downloadDeviceList device_list req onSuccess
SmartHome 400797:[DEBUG]-04-09 17:50:55.731 processResult in result={“code”:0,”message”:”ok”,”result”:{“list”:[{“did”:”9yyyyyy6″,”token”:”6c69xxxxxxxxxxxxxxxxxx63334d41“,”longitude”:”0.00000000″,”latitude”:”0.00000000″,”name”:”Mi Robot Vacuum”,”pid”:”0″,”localip”:”192.xxx.yyy.zzz”

 

This was the token that we were going to need to plug into home-assistant. For good housekeeping, I dumped this into the secrets.yaml file, and then proceeded to add the following code into my main config.yaml.

vacuum:
– platform: xiaomi_miio
host: 192.YYY.XXX.ZZZ
token: !secret xiaomi

 

With that, I ran my configuation check and restarted Home-Asssistant. On restart i was met with the following entity:

vacuum.xiaomi_vacuum_cleaner

 

I then set about adding this to lovelace as you can see below.

Xiaomi Robot Vacuum

Xiaomi Robot Vacuum 

When you click on the vacuum icon, it brings up the following attributes and controls:

Xiaomi Vacuum State Lovelace

Xiaomi Vacuum State Lovelace 

Here you can see it in the states table

Xiaomi Vacuum State Attributes

Xiaomi Vacuum State Attributes 

I played with the controls and the little robotic helper roared into life with it’s little blades spinning turbo!

At this point, i was happy to be able to control the vacuum independent of the horrid app. Next on the list was to sort out the configuring of specific zones and full voice control.

Keep an eye out for the next installment which I hope to publish in the next few days!

Comments

Leave a Reply