Howto: Xiaomi vacuum zoned cleaning

I got it to work by calling your script directly from IFTTT with the folowing line:

{ "action": "call_service", "service": "python_script.vacumm_send_command", "command": "app_segment_clean", "params": "20", "entity_id": "vacuum.roborock" }

But now i want to use a textfield in there so when i say clean kitchen, living room or bathroom it will change it to the numer 18,17 or 20.

can i do this in your python script? Or should i do this in home assistant?

You should do it in HA script that will take a name of room as a parameter and call python script with a matching room number.

Any exmaples or directions i can look into, i was already trying this but cant get it to work yet.

Would it not be posible to do somthing like this:

for z in params.replace('kitchen', '20'):

You are right, it will be easier to do it in python.

I think the easiest way would be something like this:

params = str(data.get('params')).replace('kitchen', '20').replace('bedroom', '19')

Thanks for your reply i edited it like this for now:

for z in params.replace('kitchen', '20').replace(' ', '').replace('],[', '|').replace('[', '').replace(']', '').split('|'):

and this seems to work actualy.
Now im trying to use your python script to add a pause command and a stop command this way i can use all these command with only 1 IFTTT applet

To answer myself and maybe help someone else out here, I ended up creating a python script which takes a string of room names (e.g. “kitchen and kids room” ) and then starts selective room cleaning like this:

python_scripts/vacuum_room.py

# Vacuum specific room(s), multiple names for a room can be used
roomConfig = {
    16: ["kitchen"],
    17: ["living room"],
    18: ["nursery", "kids room"]
}

entity_id = data.get("entity_id")
area = data.get("area").lower()

roomsToClean = []

for roomNumber, roomNames in roomConfig.items():
    for name in roomNames:
        if name in area: 
            roomsToClean.append(int(roomNumber))
            continue

if entity_id is not None and len(roomsToClean) > 0: 
    service_data = {"entity_id": entity_id, "command": "app_segment_clean", "params": roomsToClean}
    hass.services.call("vacuum", "send_command", service_data, False)

I’ve summarized my working setup in full here:
https://community.home-assistant.io/t/selective-room-cleaning-with-google-assistant-and-xiaomi-roborock-s6-using-ifttt/

Sorry for the late reply, but my/this very first post includes a home assistant script in combination with iftt to do exactly that what you asked for.

Haha, this thread has grown so long I forgot that it started with a really well put together tutorial :sweat_smile:

Our scripts differ a little bit though:

  • Mine relies on rooms already set up in the Roborock app while yours uses manually defined zones
  • My script supports cleaning of multiple rooms with one command, i.e. “ok google, clean the kitchen and the office and the hallway”
  • My script is not case sensitive
  • I’m using one python script for cleaning all rooms compared to one regular script for each room

I’ve obviously gotten a lot of inspiration from here which I’m really grateful for but I also think the use cases for each script is a little bit different :slight_smile:

2 Likes

I see. I haven’t updated my automationb(since there was no need for it) , but I am going to move soon so I might adopt your method then.

Cheers

Hello all,

can somebody help me with a tutorial to connect Xiaomi Robot Vacuum to HA?

1 Like

Friends! How to “geolocate” the vacuum cleaner in the form of a list if the coordinates of the rooms are known?
For example, if the robot is in zone [11111, 22222, 33333, 4444, 1] while cleaning, the message “Bedroom” is returned, [55555, 66666, 77777, 88888, 1] - “Living room”, etc.?

For those interested:

http://tuxsavvytech.42web.io/2021/02/19/send-xiaomi-1c-stytj01zhm-to-different-rooms-using-home-assistant/

1 Like

What about multi floor/map?
I have 2 floors and the segments id’s are the same for all the floors (starting in 17).

How can i send the floor/map id via HA when i locate the vaccum in other floor that the one selected in mi home app?

Thank you in advance.

Roborock S5 Max here!

1 Like

Already implemented a workaround.
Start the general vaccum start clean service, so the vaccum start positioning and load the correct map, then stop, and then send clean by the respective segments!

1 Like

Hi. Is there a tutorial on how to install it into HA?

You should use miio integration to add your vaccum in HA.

Dears,

I want to use nodered, but the service xiaomi_clean_zone is not working. How I can use the zone cleaning with nodered?. Anyone can share the entiry flow?.

Thanks in advance,

Jose

The command is deprecated. You have to use xiaomi_miio.vacuum_clean_zone.

Please refer to the docs

how do i get map numbers?

how do i use it

miiocli vacuum --ip <ip of the vacuum> --token <your vacuum token> get_room_mapping
Bash

I searched google but I didn’t find a guide on how to get zone numbers