Use Roborock app and control vacuum from Home assistant at the same time

Hi all,

Long time lurker, first time poster.

I have seen a lot of people over the internet asking about using the Roborock app and Home assistant at the same time.

I know that the general consensus is to move over to the Xiaomi app, and get the token etc, but I prefer the Roborock app, and have it setup with my family etc. So I decided to get it working.

I managed to reverse engineer the app, and work out how to communicate with the device locally which is actually an option in the code, I don’t know exactly why it doesnt use it, or if there is certain circumstances it will do it, maybe just for certain commands…

So I managed to work out, that instead of using the Xiamoi protocol (https://github.com/marcelrv/XiaomiRobotVacuumProtocol), that isn’t what it does any more.

To communicate locally with the device, it uses the Tuya protocol. It sends a DPS of 101, and a Base64 encoding of the the vacuum protocol (above). It does this using the device ID and the key (the same one that is used).

Furthermore, I have worked out how to get the map using Tuya mqtt server. I managed to get the details to log in to your account, but they seem to match this persons finding here in terms of how they are created (Link in second post). The mqtt command I am using to get the map is: -

mosquitto_sub -v -h m1.tuyaeu.com -u p******* -P ************ -t m/m/i/<roborock_device_id>

It is possible to subscribe, and by sending the get_map_v1 request (see first link) locally, it will make the mqtt spit out the encrypted map. It needs to be request with a new JSON object though: -

"security":{"endpoint":"****","nonce":"<AES generated key>"}

It is possible to retrieve the “endpoint” from SharedPreferences.

I have a python script that can take the data from the map and decrypt it so it can be used with RoborockMapViewer.

So, next steps:

I have created this git repo with the script for decrypting the map (https://github.com/89jd/roborock_comms). I will add to the README at some point the findings from this post.

I am not sure on the best way of making it possible for everyone to be able to access the values that come from the app, that are needed to make all this possible, so interested in hearing what everyone thinks about that.

Took a fair bit of effort to get to here. But good to know that it is still all possible to do local comms with roborock, and to get the map without having to root it.

Cheers

3 Likes

https://github.com/Ericmas001/Tuya-Api-Tools/wiki/Requests -> This explains the login details for MQTT

1 Like

So I have the S4 MAX which has to use the new roborock app. Did you get any more integration into HA?

I have the same S4 max, but I use MiHome app on my phone.
at the same time HA can send messages to the vac directly or through node red.

I was under the impression that the Roborock app resets the token each binding moment. is this still the case or has this changed?

@nontijt how did you get the S4 max into MiHome? When I try to discovery it never finds it.

You can’t add the S4 Max into MiHome app. It only works with the Roborock app which means it’s not possible to get the token needed to integrate with Home Assistant unfortunately. I’ll be returning mine for that reason.

I suspect @nontijt had a typo and meant to say S5 Max.

Your right. I got confused. Its the s5 max. Sorry.

1 Like

Thats what I thought. We put so much research into which robo-vac to get, I guess I’m stuck with it. Hopefully some community development down the road finds a way :confused:

I actually have three Roborocks in my home currently (S4 Max, S6, S6 Pure) while I figure out which one to keep. I can definitely say the S4 Max is easily the best of those three models. It’s the quietest, has the best suction by far, smartest navigation, longest battery life.

My S6 Pure for example gets stuck in places where the S4 Max had no issues at all. Even though I’ve gotten that one integrated into HA, if I can’t trust it to vacuum by itself without getting stuck, I’m not sure how useful that is going to be…

So I might end up just keeping my S4 Max too in the end, still have a few more weeks before my return period is up to decide. Even though you can’t get the S4 Max into Home Assistant yet, it’s still a fantastic smart vacuum :slight_smile:

Checking to see if the S4 Max has been looked into further. Maybe finding the specs by taking it apart and whatnot. I’m afraid to take mine apart and don’t mind using the Roborock app, but local control would be best. Not sure what the big difference is between the S4/S5/S5 Max/S6, maybe they swapped some components?

I just checked the Mi Home app and the Roborock S4 Max now shows up as a device you can add (screencaps below). So they’ve added Mi Home support sometime within the last three weeks. It no longer requires the Roborock app.

This means the S4 Max should work with Home Assistant now. I just re-purchased one and should be able to test within a few days.

I’m excited to see what you figure out. I hacked together some automation by using the Google Assistant Relay to control the room based cleaning from Home Assistant. It works pretty well, but full integration would be even better!

I got my S4 Max and successfully integrated into Home Assistant.

The “trick” is to set it up in the Roborock app first and download the latest firmware updates. The latest firmware has bug fixes and/or compatibility updates that allows it to work with the Mi Home app. Once it’s in the Mi Home app you can use the Xiaomi Cloud Tokens extractor to get the token you need to integrate in HA.

S4 Max works almost perfectly in Home Assistant aside from one small quirk I’ve noticed. Occasionally there is a small delay before a command runs. The command always works, but it can sometimes take an extra 3-5 seconds before it starts. Doesn’t bother me at all, but my S6 and S6 Pure didn’t have that delay, so thought it was worth mentioning.

2 Likes

I’ve heard/read in other places that the token is now rotating and stops working after a bit. Have you experienced that?

That hasn’t been my experience, I’ve had three Roborocks in HA now and the tokens have remained stable so far.

From what I’ve read the token changes when resetting WiFi settings and sometimes when updating the firmware - both of which are things that you’ll do very rarely.

Apparently it also changes if you use the Roborock app, but once you get it set up in Mi Home you can just use that and will never have to touch the Roborock app again.

For anybody else looking to do this.

I moved from the Roborock App to the MiHome app. All my floorplans moved as well, I just had to re-label the rooms. Works great!

Hey @SeanM… sorry one more question. Do you use the multi-level portion? I’ve done a decent amount of searching and haven’t found a way to tell the vacuum from HA if its 17 on one map vs 17 on another map.

Thanks!

I considered doing this, but the Alexa integration when my S7 is connected through the MiHome app is significantly limited compared to the Roborock app/Alexa integration. With the latter, I can tell Alexa to clean a specific room, but the MiHome Alexa integration only has start/stop unless I’m mistaken?

Do you ever still use the Mi Home or Roborock app after connecting to HA?

While my goal is to connect my S4 Max to HA and use it primarily through there, I still like having a reliable backup method. So I’m curious which app you have to use after connecting it to HA.

One of use cases that I have is that I’d like to use camera on my S7 vmax Ultra and I only can do it through roborock app. The Mi Home won’t let me view camera feed from the app.
And yet, I’d love my s7 to be integrated with homeassistant so I don’t have false intrusion alarms from a room, when HA knows there is vacuum working in that room.

3 Likes