Howto: Xiaomi vacuum zoned cleaning

Suggestions/Improvements:

  1. Multiple room zoned cleaning - clicking on multiple rooms in any UI should queue up in the zoned cleaning.
  • One way to achieve this could be to use input_boolean for each room and then use a string global variable (custom component https://github.com/rogro82/hass-variables) to store the zones to be cleaned. This string can be using in the zone cleaning command.
  • Another way could be using the scripts and wait_template commands within the scripts. So, if I fire up the script for room A, and then the one for room B -> B will wait for A to finish before starting.
  1. Number of passes can be stored in input_number and used in the scripts. https://www.home-assistant.io/components/input_number/
1 Like

I am having issues that no matter what command Google and IFTTT pass on it only will clean the kitchen. Below is the full set of scripts. I m sure it is easy what i am doing wrong, i know the bottom scripts work to clean the proper zones when i call them via HA.

vacuum_room_select:
      sequence:
        - service: script.turn_on
          data_template:
            entity_id: >
              {% if (room== "kitchen" or "the kitchen") %}
                script.vacuum_kitchen
              {% elif (room== "living room" or "the living room") %}
                script.vacuum_living_room
              {% elif (room== "pantry" or "the pantry") %}
                script.vacuum_pantry
              {% elif (room== "dining room" or "the dining room") %}
                script.vacuum_dining_room
              {% elif (room== "spare bedroom" or "the spare bedroom") %}
                script.vacuum_spare_bedroom
              {% elif (room== "spare bathroom" or "the spare bathroom") %}
                script.vacuum_spare_bathroom
              {% elif (room== "computer room" or "the computer room") %}
                script.vacuum_computer_room
              {% elif (room== "front bathroom" or "the front bathroom") %}
                script.vacuum_front_bathroom
              {% elif (room== "entry hall" or "the entry hall") %}
                script.vacuum_entry_hall
              {% elif (room== "go home" or "go to your home" or "go to dock" or "go to base") %}
                script.vacuum1_home
              {% elif (room== "stop cleaning" or "stop" or "stop vacuuming") %}
                script.vacuum1_stop       
              {% endif %}

vacuum1_stop:
      alias: "Vacuum Stop"
      sequence:
        - service: vacuum.send_command
          data:
            entity_id: vacuum.rosy
            command: stop

vacuum1_home:
      alias: "Vacuum go home"
      sequence:
        - service: vacuum.send_command
          data:
            entity_id: vacuum.rosy
            command: return_to_base

vacuum_kitchen:
      alias: "Vacuum the Kitchen"
      sequence:
        - service: vacuum.send_command
          data:
            entity_id: vacuum.rosy
            command: app_zoned_clean
            params: [[22500, 30000, 28500, 33750, 2]]

vacuum_pantry:
      alias: "Vacuum the Pantry"
      sequence:
        - service: vacuum.send_command
          data:
            entity_id: vacuum.rosy
            command: app_zoned_clean
            params: [[19500, 30500, 23500, 32000, 2]]

vacuum_living_room:
      alias: "Vacuum the Living Room"
      sequence:
        - service: vacuum.send_command
          data:
            entity_id: vacuum.rosy
            command: app_zoned_clean
            params: [[25500, 25250, 30000, 31000, 2]]

vacuum_dining_room:
      alias: "Vacuum the Dining Room"
      sequence:
        - service: vacuum.send_command
          data:
            entity_id: vacuum.rosy
            command: app_zoned_clean
            params: [[22000, 25250, 26500, 30000, 2]]

vacuum_spare_bedroom:
      alias: "Vacuum the Spare Bedroom"
      sequence:
        - service: vacuum.send_command
          data:
            entity_id: vacuum.rosy
            command: app_zoned_clean
            params: [[30500, 25000, 34000, 28500, 2]]

vacuum_spare_bathroom:
      alias: "Vacuum the Spare Bathroom"
      sequence:
        - service: vacuum.send_command
          data:
            entity_id: vacuum.rosy
            command: app_zoned_clean
            params: [[31750, 28750, 33250, 30500, 2]]

vacuum_computer_room:
      alias: "Vacuum the Computer Room"
      sequence:
        - service: vacuum.send_command
          data:
            entity_id: vacuum.rosy
            command: app_zoned_clean
            params: [[28500, 30500, 34000, 34750, 2]]

vacuum_front_bathroom:
      alias: "Vacuum the Front Bathroom"
      sequence:
        - service: vacuum.send_command
          data:
            entity_id: vacuum.rosy
            command: app_zoned_clean
            params: [[31000, 37750, 34000, 38750, 2]]

vacuum_entry_hall:
      alias: "Vacuum the Entry Hall"
      sequence:
        - service: vacuum.send_command
          data:
            entity_id: vacuum.rosy
            command: app_zoned_clean
            params: [[28500, 31000, 31000, 40000, 2]]

I’m surprised that you don’t get some sort of syntax error as I’m pretty sure your if statements should say

room==“kitchen” or room==“the kitchen”

Patrick is right.

What I am using (also to avoid an issue with capital/lower case letters) is the following:

      {% if 'kĂźche' in raum|lower %}
        script.saugen_kueche
      {% elif 'fliesen' in raum|lower or 'fließen' in raum|lower%}
       script.saugen_fliesen
      {% elif 'flur' in raum|lower %}
       script.saugen_flur
      {% elif 'bad' in raum|lower %}
       script.saugen_bad
      {% elif 'wischen' in raum|lower %}
       script.saugen_wohnzimmer_wischen
      {% elif 'wohnzimmer' in raum|lower %}
       script.saugen_wohnzimmer
      {% elif 'teppich' in raum|lower %}
       script.saugen_teppich
      {% elif 'parkett' in raum|lower %}
       script.saugen_parkett
      {% elif 'schlafzimmer' in raum|lower %}
        script.saugen_schlafzimmer
      {% elif 'wohnung' in raum|lower %}
        script.saugen_wohnung
      {% endif %}

You would not have to check for “the” anymore, since it looks for the room name in your sentence. “raum|lower” just takes the word that was passed through IFTTT and makes it lower case (in German nouns are capitalized but Google for some reason fails to capitalize them, so to avoid errors and made them all lower).

I think you guys/gals are doing great work, can wait to start playing. One question, has anyone mapped a room and set up a program to go around a rug? I have a few high pile rugs a Rosie gets stuck, so it would be nice to be able to tell her to avoid certain areas.

Thanks

If you have the new firmware you should in theory be able to create “no-go” areas. Although this isn’t implemented in HA yet, you still should be able to send the command in raw format to the vacuum - but I haven’t looked into that at all.

It’s disappointing that the v1 Mi Robot Vacuum isn’t getting the software updates for the no-go areas and the ability to save the map. Especially since they are seemingly very similar in their sensors. I think those 2 abilities, and the ability to set zone names so you can tell it, “Hey Google, vacuum the Kitchen”, would really push this to the next level.

^
Well, this you can do with the v1 already if you use HA and IFTTT as described in this howto

Thanks this was way easier!

I tried to implement the multiroom selection feature with input_booleans for each room. The following scripts then go through all my rooms and check if the input_boolean for the room is selected. If the boolean is selected a script containing the correct zone coordinates is called:

  vacuum_clean_room:
    alias: Raum reinigen
    sequence:
      - condition: template
        value_template: "{{ is_state(room_bool, 'on') }}"
      - service: script.turn_on
        data_template:
          entity_id: '{{ room_cleaner }}'
      - delay: '00:00:30'
      - wait_template: "{{ (is_state('vacuum.roborock', 'docked'))or (is_state('vacuum.roborock', 'idle'))}}"
      - service: input_boolean.turn_off
        data_template:
          entity_id: '{{ room_bool }}'
      - delay: '00:00:01'
  vacuum_selected:
    alias: Auswahl saugen
    sequence:
      - service: script.vacuum_clean_room
        data_template:
          room_cleaner: script.vacuum_wohnzimmer
          room_bool: input_boolean.wohnzimmer
      - wait_template: "{{ is_state('script.vacuum_clean_room', 'off') }}"
      - service: script.vacuum_clean_room
        data_template:
          room_cleaner: script.vacuum_bad
          room_bool: input_boolean.bad
      - wait_template: "{{ is_state('script.vacuum_clean_room', 'off') }}"
      - service: script.vacuum_clean_room
        data_template:
          room_cleaner: script.vacuum_kueche
          room_bool: input_boolean.kueche
      - wait_template: "{{ is_state('script.vacuum_clean_room', 'off') }}"
      - service: script.vacuum_clean_room
        data_template:
          room_cleaner: script.vacuum_schlaf
          room_bool: input_boolean.schlafzimmer
      - wait_template: "{{ is_state('script.vacuum_clean_room', 'off') }}"
      - service: script.vacuum_clean_room
        data_template:
          room_cleaner: script.vacuum_flur
          room_bool: input_boolean.flur

I still have a problem though, because my xiaomi vacuum has to return to the dock after every zone cleaning. It seems I can’t stop it from returning with any command from home assistant and can’t get it to start an other zone cleanup, before it is in the dock.
Anyone has any idea how I can improve my scripts or stop the vacuum on the way back to the dock?

3 Likes

I just had some time and tried to build a string containing all the zones I want to clean from the input_booleans and give it to the app_zoned_clean command in one go. I then realized that the list that is given to the command in fact is no string and as it seems it is not allowed to be a string.
It didn’t work everytime I tried to use data_template instead of data for the command like this:

  - service: vacuum.send_command
    # not working!
    data_template:
      entity_id: vacuum.roborock
      command: app_zoned_clean
      params: [[21000, 23200, 23900, 27200, 1]]

or this

  - service: vacuum.send_command
    # not working!
    data_template:
      entity_id: vacuum.roborock
      command: app_zoned_clean
      params: '{{ zones }}'

I think data_template interprets every input paramater as string. Because I cannot use data_template I also can’t give it a list via script. Everytime I tried, the vacuum said it started the zoned_cleanup, but it didn’t have any zone and just started a full cleanup instead.
Also it seems to be impossible to make one script that checks an input_number and changes the number of times the zone should be cleaned according to it, because we can’t use the input_number as a parameter in the list without templates.
Did nobody else encounter this problem or am I just missing something obvious?

Also tried and couldn’t use a data_template for that service, I suppose it is a limitation on the service definition.

Still then, as a heads-up, I tried building a string with 7 division coordinates (fixed ones) and it stopped after the 5th, it seems like a limitation, because it ran ok until the 5th and stopped. This would be ok if it wasn’t for this limitation, because actually vacuum doesn’t go to the dock between different division coordinates.

Hello.

May I ask where did you get that information about the v1 and the fact that it won’t get the updates with the ability to save maps and no-go areas?

Thanks

Am i being dense … how do you find the x y cordinates …trail and error?

are you guys having issues with regular cleanup mode in latest firmware? Zone clean up works perfectly but now my xiaomi vac v1 is randomly missing entire areas (sometimes entire room) to clean which has never happened before on older firmware.

Flolevac is an Android app that can help you:

Basically, yes. There are different methods described in this thread how to find out all the coordinates that you need - for example by creating a map yourself with the respective coordinate grid or use the app FloleVac to manually set your cursor to the points where you want your area to be - the app then tells you the coordinates (as far as I know)

I had a weird issue where it wouldn’t go into a room because it said there was no path - looking at the map it apprarently went by the room when the door was closed but would not update the current map when right in front of the clear path… But I got another fm update just last night - maybe this was a bug and got fixed?

I got it from the post above by mouth4war. Howto: Xiaomi vacuum zoned cleaning

So do we/I need to update the app in order to up date FW for my V2 bot, and does this need the API key will be changed and I’ll have to go throw this process to obtain it again ?
Thanks :blush:

In the app you can check if there is a firmware upgrade and then indeed install it.
API should stay the same so no need to do anything there.