Howto: Xiaomi vacuum zoned cleaning

Why donā€™t you use the clean segment command where you basically enter the ID of the room that was created in the app? That should be a bit easier.

I wish I could use the room IDs, that would be more straightforward but I couldnā€™t figure out where to find them in the Xiaomi Home app šŸ¤·

Just use the command and test with different ids (starting from 1), you then see in the app which room the vac is going to clean. If you modify rooms in the app, they usually get a new ID (so a number higher than your actual room count) and their prior ids then just gonna be unused.

To be able to use the room cleaning you need to make sure to have finished a full clean so that the app is going to create the rooms

Iā€™m using the Xiaomi integration plus the cloud Map extractor. I want to be able to pull out the rooms easierā€¦but not sure how to install the MauricioXavier13/vacuum_miio. I tried via HACS, but the repository was not listed in HACs and I could not install it as a customer repository.

Looking at your Mi Home picture map, not sure if your vacuum was able to properly determine rooms.

Please start from the Mi Home vacuum function ā€˜Edit zoneā€™, to make sure all your individual rooms are identified (usually coloured in different colours in the map).

After this, if you have access to a Debian environment with Python, you can get your rooms, by doing the following:

  1. Install Python Miio
  2. Follow instructions in https://www.home-assistant.io/integrations/xiaomi_miio/#retrieving-room-numbers.

Please let us know if you succeed, as getting this to work will make your life MUCH easier in getting HA to control your vacuum.

1 Like

Trying to retrieve the room IDs with miiocli was kind of a failure as described here.

The good news is I managed to find the right combination in my script using the zone coordinates but with a different service :tada:

service: xiaomi_miio.vacuum_clean_zone
target:
  entity_id: vacuum.vacuum
data:
  zone:
    - - 28625
      - 23989
      - 32288
      - 27123
  repeats: 1
1 Like

Do you know if itā€™s possible to add repeats to this method?

Hi, in the script is it possible to add the suction power? Thanks

Same problem hereā€¦ were you able to resolve it?

May I ask you how did you get the zone coordinates?

I got the coordinates following this video, especially at this precise time Roborock Vacuum // Zone & Voice Assistant Control in Home Assistant - YouTube
The trick is to use debug: true
Itā€™s very well explained and following this guyā€™s tutorial I was able to create this card

Its yaml code is :

type: vertical-stack
cards:
  - type: custom:xiaomi-vacuum-map-card
    map_source:
      camera: camera.xiaomi_cloud_map_extractor
    calibration_source:
      camera: true
    entity: vacuum.vacuum
    vacuum_platform: default
  - type: button
    tap_action:
      action: toggle
    entity: script.vacuum_kitchen_with_zone
    show_icon: true
    show_name: true
    name: Vacuum Kitchen
    show_state: true

The buttonā€™s script above (script.vacuum_kitchen_with_zone) is :

alias: Vacuum kitchen with zone
sequence:
  - service: xiaomi_miio.vacuum_clean_zone
    target:
      entity_id: vacuum.vacuum
    data:
      zone:
        - - 28625
          - 23989
          - 32288
          - 27123
      repeats: 1
mode: single
icon: mdi:robot-vacuum

Hope this helps !

2 Likes

Do you know if you can select the ā€œCleanup Modeā€ as part of your script?
I assume this is possible via ā€œSend_Commandā€ but I donā€™t know where to find a list of command codes.


Selecting Vacuum Only prevents the unit from cleaning the mop, a waste when cleaning carpet only rooms.

Sorry for the late response.
I donā€™t know much about those vacuum options and I heavily rely on video tutorials and posts on this forum.
I found the correct syntax above after quite some research and tests.
It really is a hit-and-miss experience :sweat:

I heavily rely on video tutorials and posts on this forum.

Which videos or posts?
Iā€™ve not seen any to change to vacuum only mode. I wonder if it is unique to the Max V Ultra (since it can clean the mop)

I was refering to this video in my earlier post

But I donā€™t know about the mode. Havenā€™t played with it myself.

conchita_pasillo:

  alias: "Conchita Pasillo"

  icon: mdi:robot-vacuum

  mode: single

  sequence:

    - service: xiaomi_miio.vacuum_clean_zone

      target:

        entity_id: vacuum.roborock_s5

      data:

        zone: [[23439,21645,24239,25295]]

        repeats: 1

Or simple like this:

alias: Run Vacuum
sequence:
  - service: roborock.vacuum_clean_segment
    data_template:
      segments: |
        {% set vacrooms = namespace(roomid=[]) %}
        {% for rooms in state_attr('sensor.roborock_rooms','rooms') -%}
          {% if is_state(rooms.boolean,'on') %}
            {% set room = rooms.id %}
            {% set vacrooms.roomid = vacrooms.roomid + [room] %}
          {% endif %}
        {%- endfor %}
        {{ vacrooms.roomid }}
    target:
      entity_id: vacuum.roborock_s7
mode: single
icon: mdi:robot-vacuum

And have a sensor with all your data in it for the rooms. Read this (of course with you data into a sensor):

{
    "rooms": [
        {
            "name": "kitchen",
            "boolean": "input_boolean.vac_kitchen",
            "id": "17"
            },
        {
            "name": "dining_room",
            "boolean": "input_boolean.vac_dining_room",
            "id": "16"
            },
        {
            "name": "foyer",
            "boolean": "input_boolean.vac_foyer",
            "id": "18"
            },
        {
            "name": "laundry",
            "boolean": "input_boolean.vac_laundry",
            "id": "20"
            },
        {
            "name": "living_room",
            "boolean": "input_boolean.vac_living_room",
            "id": "19"
            },
        {
            "name": "master_bedroom",
            "boolean": "input_boolean.vac_master_bedroom",
            "id": "21"
            },
        {
            "name": "master_bathroom",
            "boolean": "input_boolean.vac_master_bathroom",
            "id": "22"
            },
        {
            "name": "guest_bathroom",
            "boolean": "input_boolean.vac_guest_bathroom",
            "id": "23"
            }
    ],
    "points": [
        {
            "name": "sink",
            "x": 17989,
            "y": 25491
         }
    ]
}

And you can have a GUI that allows you to select one or more rooms and clean them:

So I select Kitchen, Dining and Foyer and say ā€œCleanā€ and away it goes.

1 Like

How do you create your sensor from the json data? Via file? Trying to figure out best way to set this up

I use this:

##
## Roborock Rooms 
##
- platform: rest
  name: roborock_rooms
  resource: http://192.168.1.245:8123/local/Roborock/roborock.json
  value_template: "{{ now() }}"
  json_attributes:
    - rooms
    - points

With this JSON file in my install:

{
    "rooms": [
        {
            "name": "kitchen",
            "boolean": "input_boolean.vac_kitchen",
            "id": "17"
            },
        {
            "name": "dining_room",
            "boolean": "input_boolean.vac_dining_room",
            "id": "16"
            },
        {
            "name": "foyer",
            "boolean": "input_boolean.vac_foyer",
            "id": "18"
            },
        {
            "name": "laundry",
            "boolean": "input_boolean.vac_laundry",
            "id": "20"
            },
        {
            "name": "living_room",
            "boolean": "input_boolean.vac_living_room",
            "id": "19"
            },
        {
            "name": "master_bedroom",
            "boolean": "input_boolean.vac_master_bedroom",
            "id": "21"
            },
        {
            "name": "master_bathroom",
            "boolean": "input_boolean.vac_master_bathroom",
            "id": "22"
            },
        {
            "name": "guest_bathroom",
            "boolean": "input_boolean.vac_guest_bathroom",
            "id": "23"
            }
    ],
    "points": [
        {
            "name": "sink",
            "x": 17989,
            "y": 25491
         }
    ]
}

Positive I could vastly improve this but it works and I have bigger things I am tackling now.

Is it possible to get a little bit more details (configuration), I would like to implement this in my home assistant instance