Support for Xiaomi Vacuum S20+ to Xiaomi Miio integration

Instead uf using siid: 6 and aiid: 7, use siid: 2, aiid: 13 and use the params for room ids:

in the first step you set the custom cleaning parameters for the room, which are now the default parameters for the room (if you look in the mi app on your phone, u’ll see that).

If you use siid: 6, aiid 7: it will start cleaning the whole map, in the order of rooms you set in the mi app.

Change it to this (only part 2 is changed bellow)

clean_couloir:
  sequence:
    # 1️⃣ Configure les paramètres de nettoyage pour le couloir
    - service: xiaomi_miot.call_action
      target:
        entity_id: vacuum.xiaomi_b108gl_8568_robot_cleaner
      data:
        siid: 2
        aiid: 10
        params:
          - "{\"room_attrs\":[{\"id\":7,\"room_name\":\"Couloir\",\"fan_level\":1,\"water_level\":1,\"clean_mode\":1,\"clean_times\":1,\"mop_mode\":0,\"on\":true}]}"

    # 2️⃣ Démarre le nettoyage avec les paramètres définis
    - service: xiaomi_miot.call_action
      target:
        entity_id: vacuum.xiaomi_b108gl_8568_robot_cleaner
      data:
        siid: 2
        aiid: 13
        params:
          - "{\"room\":[7]}"

Attribut from Home Assistant is : `
vacuum_extend.status_extend: 0
vacuum_extend.room_info: {"version":2,"room_attrs":[["id","room_name","fan_level","water_level","clean_mode","clean_times","mop_mode","on"],[3,"Couture",2,1,3,1,0,false],[4,"Salon",2,1,1,1,0,true],[5,"Cuisine",2,2,1,1,0,false],[6,"Wc vestiaire",2,2,1,1,0,false],[7,"Couloir",2,1,1,1,0,false]]}

This will send it to room 7

Thanks it’s working but only for sweep. When i tried with clean_mode set on 3 the robot continue sweeping only and no sweep and mop

If you go into Developer tools, States, Filter entity for the vacuum cleaner, and for your vacuum cleaner, like for example mine:

image

find the attributes for it, look for one which starts with vacuum_extend.room_info:

how mines looks:

vacuum_extend.room_info: {"version":2,"room_attrs":[["id","room_name","fan_level","water_level","clean_mode","clean_times","mop_mode","on"],[3,"Hodnik",4,3,3,1,0,true],[4,"Kids' room",4,1,3,1,0,true],[5,"Garderoba",4,3,3,2,0,true],[6,"Kuhinja",4,3,3,2,0,true],[7,"Spalnica",4,1,3,1,0,true],[8,"",2,1,3,1,0,false],[9,"Living room",4,3,3,1,0,true],[10,"",2,1,3,1,0,true]]}

Can you copy & paste yours?

vacuum_extend.room_info: {"version":2,"room_attrs":[["id","room_name","fan_level","water_level","clean_mode","clean_times","mop_mode","on"],[3,"Couture",1,2,1,1,0,false],[4,"Salon",1,2,1,1,0,false],[5,"Cuisine",1,2,1,1,0,false],[6,"Wc vestiaire",1,2,3,1,0,true],[7,"Couloir",1,2,1,1,0,false]]}

Because now i tried for “Wc vestiaire room”

You don’t have clean mode set to 3 for Room with id 7:

[7,"Couloir",1,2,1,1,0,false]

the 3rd number would have to be a 3, so it should state:

[7,"Couloir",1,2,3,1,0,false]

So the code from before should be:

clean_couloir:
  sequence:
    # 1️⃣ Configure les paramètres de nettoyage pour le couloir
    - service: xiaomi_miot.call_action
      target:
        entity_id: vacuum.xiaomi_b108gl_8568_robot_cleaner
      data:
        siid: 2
        aiid: 10
        params:
          - "{\"room_attrs\":[{\"id\":7,\"room_name\":\"Couloir\",\"fan_level\":1,\"water_level\":1,\"clean_mode\":3,\"clean_times\":1,\"mop_mode\":0,\"on\":true}]}"

    # 2️⃣ Démarre le nettoyage avec les paramètres définis
    - service: xiaomi_miot.call_action
      target:
        entity_id: vacuum.xiaomi_b108gl_8568_robot_cleaner
      data:
        siid: 2
        aiid: 13
        params:
          - "{\"room\":[7]}"

The only thing changed was in the 1st part, clean_mode: 3.

Thank you very much susko, but I had already made the right code but it didn’t work for me. I finally found a solution that suits me: make a script in sequence for each room with siid2 and aiid10 to select the rooms (false or true) then clean_mode (1,2,3,4) and at the end do a siid6 aiid7 to apply the settings and this works as I want.

Hi,
I’m struggling with my S20+ and it won’t listen, it goes to a specific room but doesn’t want to do the scheduled action.
Could you send your script?

Can you copy & paste your room setup and the command you send that is not working?

This is my script

sequence:
  - action: xiaomi_miot.call_action
    metadata: {}
    data:
      entity_id: vacuum.xiaomi_b108gl_0b18_robot_cleaner
      siid: 2
      aiid: 10
      params:
        - >-
          {"room_attrs":[{"id":4,"room_name":"Korytarz","fan_level":1,"water_level":1,"clean_mode":1,"clean_times":1,"mop_mode":0,"on":false}]}
  - action: xiaomi_miot.call_action
    metadata: {}
    data:
      entity_id: vacuum.xiaomi_b108gl_0b18_robot_cleaner
      siid: 2
      aiid: 13
      params:
        - "{\"room\":[4]}"
alias: Test odkurzacza korytarz
description: ""

Vacuum cleaner does not accept command changes from the first part of the script.
When I paste:

- "{\"room_attrs\":[{\"id\":4,\"room_name\":\"Couloir\",\"fan_level\":1,\"water_level\":1,\"clean_mode\":1,\"clean_times\":1,\"mop_mode\":0,\"on\":false}]}"

it changes to:

- >-
{"room_attrs":[{"id":4,"room_name":"Korytarz","fan_level":1,"water_level":1,"clean_mode":1,"clean_times":1,"mop_mode":0,"on":false}]}

The effect is that it goes to room 4 and does what it had memorized in the mobile app (e.g. mopping). It doesn’t change the settings.

You are missing one quote and one backslash at the params:

params:
        - >-
          {"room_attrs":[{"id":4,"room_name":"Korytarz","fan_level":1,"water_level":1,"clean_mode":1,"clean_times":1,"mop_mode":0,"on":false}]}

should be

params:
        - "{\"room_attrs\":[{"id":4,"room_name":"Korytarz","fan_level":1,"water_level":1,"clean_mode":1,"clean_times":1,"mop_mode":0,"on":false}]}

See the examples from @jumate here: Support for Xiaomi Vacuum S20+ to Xiaomi Miio integration - #7 by jumate

@susko actually, perry is not far from being right, except he shouldn’t add the - before >-. This would work:

params: >-
  {"room_attrs": ...}

there is also another way to avoid escaping all the quotes, by using the yaml format for multiline string, e.g.:

action: xiaomi_miot.call_action
data:
  siid: 2
  aiid: 8
  entity_id: vacuum.xiaomi_b108gl_ae22_robot_cleaner
  params: |
    {"room": []}

This will return the current config for your rooms

With multiline, also greater readability is possible:

action: xiaomi_miot.call_action
data:
  siid: 2
  aiid: 10
  entity_id: vacuum.xiaomi_b108gl_ae22_robot_cleaner
  params: >-
    {"room_attrs": [
      {"id": 3,
      "room_name": "Kitchen",
      "fan_level": 1,
      "water_level": 1,
      "clean_mode": 1,
      "clean_times": 1,
      "mop_mode": 0,
      "on": true}
      ]
    }

Is there any way to use external references in this action so that the selected rooms can be dynamically chosen?

I have recently upgraded to the s20+ from an Ecovacs model. I have various buttons set up on a wall tablet to select rooms to be cleaned. I have a template sensor that output’s comma separated numbers based on the rooms selected.

I have the following action set up as a script which is triggered on a button press:

action: xiaomi_miot.call_action
data:
  entity_id: vacuum.xiaomi_b108gl_3de0_robot_cleaner
  siid: 2
  aiid: 13
  params: |
    {"room": [{{ states('sensor.vacuum_rooms') }}]}

But it doesn’t seem to work. I am a novice when it comes to yaml/jinja etc so this may be completely the wrong syntax to be using. Any ideas?

This should be (only change is last line, the params):

action: xiaomi_miot.call_action
data:
  entity_id: vacuum.xiaomi_b108gl_3de0_robot_cleaner
  siid: 2
  aiid: 13
  params: 
    - "{\"room\": [{{ states('sensor.vacuum_rooms') }}]}"

From example, when passing multiple rooms:

- "{\"room\":[6,6,9,9,3,3]}"

Thanks for the reply!

This doesn’t seem to work either unfortunately. I’ve tried running it from dev tools>actions too to rule out any issues with the script.

Interestingly, when I enter {{ states('sensor.vacuum_rooms') }} Into dev tools>template then I get the following result:

[
4,
5
]

Is this normal? The state seems to be correct when viewed in dev tools>states

yes.

remove the in the params line and try again

The space after params: ? I have removed that but still no joy unfortunately.

This is the exact action I’m trying to run:

action: xiaomi_miot.call_action
data:
  entity_id: vacuum.xiaomi_b108gl_3de0_robot_cleaner
  siid: 2
  aiid: 13
  params:
    - "{\"room\": [{{ states('sensor.vacuum_rooms') }}]}"

This is also my template sensor if that makes any difference, although it does seem to be outputting the correct state:

{{ states.input_boolean | selectattr("entity_id","search","vacuum_room") | selectattr('state','match','on') | map(attribute='entity_id') | map('replace', 'input_boolean.vacuum_room_', '') | join(",") }}

sorry, looks like the commenting remove what I actually wrote.

remove the

[ ] 

in the params line… if they are already included in the states(‘sensor.vacuum_rooms’) they are probably passed twice then?

I don’t believe they are being passed by the states(‘sensor.vacuum_rooms’)

When I check the state in dev tools I just see 4,5

Unless I’m doing something wrong it seem’s like we can’t use references to sensor states within the action yaml. Maybe there’s away around it that I’m missing

S20 works with HACS integration “Xiaomi Miot Auto”