Xiaomi Vacuum S1/S60/T60/S61/T61 room cleaning by room name

I hadn’t found a way to do it easily, but I just used the developer section to send a command to app_segment_clean with various numbers. I had the xiaomi app open when I did it, and you could see which rooms were highlighted.

I wrote those down, and then created scripts to clean different areas, for example, this is the script to vacuum the living areas

'1587342280896':
  alias: Vacuum Living Areas
  sequence:
  - data: {}
    entity_id: vacuum.xiaomi_vacuum_cleaner
    service: vacuum.pause
  - delay: 00:00:01
  - data:
      command: app_segment_clean
      entity_id: vacuum.xiaomi_vacuum_cleaner
      params:
      - 16
      - 18
      - 19
      - 20
      - 22
      - 24
    entity_id: vacuum.xiaomi_vacuum_cleaner
    service: vacuum.send_command
4 Likes

Brilliant, @dgaust!! Used your script and by trial and error, I am slowing getting all my rooms set up on my HA. Thanks for sharing. That was exactly the guidance I needed to get started.

I was using the coordinates method on this past, but I often had to break a room into many boxes in order to get the job done. With this, the cleaning pattern in much better.

get_room_mapping gives me an array with 6 rooms numbered 16-22, which matches my setup. However, when trying to clean a specific room it always goes to the same one (it lights up in the Mi Home app as well). Any idea what’s going on?

Did it actually went to the same room each time or you did not wait and stop it? When I was figuring out the rooms I’ve put 20s delay before pausing it and trying next number. I’ve seen similar behaviour without delay.

Thanks, that was it! I was too busy going by the map in the Mi Home app to actually see if the vacuum went to the correct room. The app shows the same room everytime, but it actually goes to the right one on command.

Hi everyone,
I just retrieved all my room numbers, and plan to write the associated scripts.
Does the room order matters when specifying the params values ?
Main bedroom and associated dressing are respectively number 4 and 6, room number 5 is a bathroom at the opposed side of the corridor. [4,5,6] will be treated differently than [4,6,5] ?
Another question, what happens if the dressing door, or another door is closed ? The vacuum will go to the next planned room or will stop because the room is unreachable ?
I could test the differents usages, but if someone already has the answers, i’ll save time.

Thank you

Thanks for the hint with cleaning by segments it’s exactly what I was looking for, I was experimenting with zone parameters, which haven’t worked for me :wink:

Currently I am receiving a notification after cleaning with cleaning time and area, I would like to get a notification with something like “Kitchen is cleaned”. Any idea how to achieve?

Trying to get room mapping with miio command but i am block with this error

miio tokens update 192.168.1.108 —token token
miio protocol call 192.168.1.108 get_room_mapping

Error Encountered an error while controlling device
Error was:
Call to device timed out

Any idea ?

thanks

Hi guys,

can you please give me a hand? I have the room numbers, I have the scripts created and the automation. However, the automation does not get triggered.
Here is my Input Select:

vacuum_house_room:
  name: Choose a room to clean
  options:
    - Select Input
    - Entrance Hall
    - Kitchen
    - Master Bedroom
    - Service Bathroom
    - Office
    - Living Room
    - Kids Bedroom
    - Master Bathroom
  initial: Select Input

Here is my automation:

- id: '1607364952707'
  alias: Start Vacuuming Room
  description: ''
  trigger:
  - platform: state
    entity_id: input_select.vacuum_house_room
  condition: []
  action:
  - service: script.turn_on
    data:
      data_template:
        entity_id: >
          {% if trigger.to_state.state == 'Entrance Hall' %}
            script.clean_entrance_hall
          {% elif trigger.to_state.state == 'Kitchen' %}
            script.clean_kitchen
          {% elif trigger.to_state.state == 'Bedroom' %}
            script.clean_bedroom
          {% elif trigger.to_state.state == 'Service Bathroom' %}
            script.clean_service_bathroom
          {% elif trigger.to_state.state == 'Office' %}
            script.clean_office
          {% elif trigger.to_state.state == 'Livingroom'%}
            script.clean_livingroom
          {% elif trigger.to_state.state == 'Kids Bedroom'%}
            script.clean_kids_bedroom
          {% elif trigger.to_state.state == 'Main Bathroom'%}
            script.clean_main_bathroom
          {% endif %}
  - delay: 00:00:30
  - service: input_select.select_option
    data:
      entity_id: input_select.vacuum_house_room
      option: Select
  mode: single

And here is the script:

clean_office:
  alias: Clean Office
  sequence:
  - service: xiaomi_miio.vacuum_clean_segment
    data:
      segments:
      - 7
    entity_id: vacuum.xiaomi_vacuum_cleaner
  mode: single
  icon: mdi:robot-vacuum

If I select Office from the Lovelace Dashboard, it does not start. If I trigger the script manually - it works fine. Any ideas? I am missing something I am sure of it.

When I try to execute the automation, the following error occurs:

While executing automation automation.start_vacuuming_room:
voluptuous.error.MultipleInvalid: extra keys not allowed @ data['data_template']

I think you don’t need data and data_template, just data and then the entity_id (at least that is how I have mine)

Does your config check show no errors?

1 Like

@pplucky - good catch - I commented data_template - and adjusted the code indent - and now it triggered. I knew it was a simple error - but 2 pair of eyes are better than one.

Thank you very much

1 Like

miio protocol call <roboip> app_segment_clean [ROOMID]

The mi home app have now a feature that you select room cleaning and select 1-3 cycles.
Anyone sniffed the traffic to see how they do that?

I see app_zoned_clean have in the parameter how many times but app_segment_clean for cleaning rooms dont have that.

We have found a solution for this, have a look here: