Multiple choice "menu" for selecting zones for vacuum clener

could you please help me in the following scenario. I would like to create a predefined list of zones for Xiaomi/Roborock S55 vacuum cleaner with a possibility to select which zone or zones should be cleaned up and then fire the cleaning up. I imagine it as a set of on-off switches named, let’s say:

  • living room
  • bedroom
  • bathroom
  • hallway

And a button “Start” (scene’s “activate”?). I am selecting bedroom and hallway, hit Start and the vacuum cleans only these 2 zones.
This is the first issue - I’ve got no idea how to design such multiselect “menu” using HA’s components. I assume that when hit the “start” HA passes a list of zones to the service call. And this is a second issue - how to pass a variable number of entries to the array of zones according to integration specs (

    - service: vacuum.xiaomi_clean_zone
        - [30914,26007,35514,28807]
        - [20232,22496,26032,26496]

Any help will be appreciated. Even the general tips from where to begin.

Not hard to do at all but will take time to setup all your zones …this is my main package for the vacuum and that package calls other packages that are basically scripts for other rooms. Dont get confused by some of it. I have door/window sensors that vacuum looks at if they are open or closed ie. the mud room (we dont want here in there so it makes sure door is closed)

Thanks for the reply Vasiley, I’ll take a look.

I made a quick analyse and wonder how do you select to clean ie. Living Room AND Kitchen in one call before the vacuum start? As far as I know, input_select allows only to select one element at a time. Unless the vaccum starts doing the first selected job and you select another and its enlisted as “TODO” on something like “vacuum_jobs_card” and the vacuum starts mentioned kitchen after it finishes cleaning living room?

with - wait_template: "{{ is_state('input_boolean.boolean_susie_home', 'on') }}"

kinda misread what you wrote …i dont have a input select for the kitchen/living room …its just a nightly routinue

OK that’s not exactly what I’d like to achieve. But thanks anyway.

I’ve found a partial solution for my issue. I’ve done menu by using input_boleans and written a template to select the zones I want to clean:

{% if is_state('input_boolean.clean_livingroom', 'on') %}
- [17514,25754,21564,32204]{% endif %}{% if is_state('input_boolean.clean_bedroom', 'on') %}
- [21665,28237,24515,32237]{% endif %}{% if is_state('input_boolean.clean_room', 'on') %}
- [24608,27075,27308,32025]{% endif %}{% if is_state('input_boolean.clean_bathroom', 'on') %}
- [24379,25119,27229,27069]{% endif %}{% if is_state('input_boolean.clean_hallway', 'on') %}
- [20821,25131,24621,28231]{% endif %}

This works perfectly in HA website’s “Templates” editor. Can anybody help me with applying this to the automation? The schema is:

    - service: vacuum.xiaomi_clean_zone
        (the above goes here as a template)

did you look thru what i gave you in my packages …I already have a input select working for every room in my house

Yes, but as I mentioned this is not exactly I’d like to achieve. As I said, I’d like to use input_booleans not input_select. I made a quick preview what I’d like. Here’s the HA controls:
and a result in Xiaomi’s app after clicking on “CLEAN!” (it’s not working for now, the screen is prepared in the app; it’s only works if I define the zones as static):

In case someone needed the solution, I figured it out.

  1. in configuration.yaml enable python scripts:
  2. in configuration.yaml create input_boolean switches:
    name: "LIVINGROOM"
    initial: off
    name: "BEDROOM"
    initial: off
    name: "NAT'S ROOM"
    initial: off
    name: "BATHROOM"
    initial: off
    name: "HALLWAY"
    initial: off
  1. create a folder where scripts will be stored: <ha_config>/python_scripts
  2. python script named
args = {"entity_id": "vacuum.xiaomi_vacuum_cleaner", "repeats": "1","zone":[]}

zone_livingroom = data.get("input_boolean.livingroom")
zone_bedroom = data.get("input_boolean.bedroom")
zone_room = data.get("")
zone_bathroom = data.get("input_boolean.bathroom")
zone_hallway = data.get("input_boolean.hallway")

if zone_livingroom == 'on':
if zone_bedroom == 'on':
if zone_room == 'on':
if zone_bathroom == 'on':
if zone_hallway == 'on':
  args["zone"].extend([[20821,25131,24621,28231]])'vacuum', 'xiaomi_clean_zone', args)
  1. scripts.yaml part:
  alias: "xiaomi clean action"
    - service: python_script.xiaomi
       input_boolean.livingroom: '{{ states.input_boolean.clean_livingroom.state }}'
       input_boolean.bedroom: '{{ states.input_boolean.clean_bedroom.state }}' '{{ states.input_boolean.clean_room.state }}'
       input_boolean.bathroom: '{{ states.input_boolean.clean_bathroom.state }}'
       input_boolean.hallway: '{{ states.input_boolean.clean_hallway.state }}'
  1. ui-lovelace.yaml:
    - type: custom:vertical-stack-in-card
            type: entities
            title: "Vacuum"
            show_header_toggle: false
              - input_boolean.clean_livingroom
              - input_boolean.clean_bedroom
              - input_boolean.clean_room
              - input_boolean.clean_bathroom
              - input_boolean.clean_hallway

          - type: entity-button
            name: "CLEAN!"
            entity: script.clean_xiaomi
            show_icon: false
              action: call-service
                entity_id: script.clean_xiaomi
              service: script.turn_on

Of course it might be done better but I’d like to show a general config. Digging community I found the info that zones cannot be templated in yaml since they accept python tables as an argument. There is an open issue on github to fix the ‘zone’ part to enable templates. So the method above is a workaround.


Hi Damian, thanks for your job.
I used your code but I don’t know how to complete the step 6 to combine the button inside the vertical stack. Now I have 2 different cards (first with boleans and 2 with button) but do not works.
Do you know how can i solve-it?

Many thanks

Hi Miquel,
can you please post a screenshot? Moreover, please note that in one of the recent Home Assistant update some services changed names and that might be the reason it is not working for you, for example in
was:‘vacuum’, ‘xiaomi_clean_zone’, args)
now it is changed to:‘xiaomi_miio’, ‘vacuum_clean_zone’, args)

I also changed the scripts.yaml a little to the recommended by HomeAssistant team form (but is is not necessary for now I think):

  alias: "xiaomi clean action"
    - service: python_script.xiaomi
       input_boolean.livingroom: '{{ states("input_boolean.clean_livingroom") }}'
       input_boolean.bedroom: '{{ states("input_boolean.clean_bedroom") }}' '{{ states("input_boolean.clean_room") }}'
       input_boolean.bathroom: '{{ states("input_boolean.clean_bathroom") }}'
       input_boolean.hallway: '{{ states("input_boolean.clean_hallway") }}'
       input_number.passes: '{{ states("input_number.xiaomi_passes") | int }}'
       input_select.power: '{{ states("input_select.xiaomi_power") }}'

Hi Damian,

This is a screenshot of my cards.

I changed the and scripts.yaml but is not working.

I’ll read again all the code looking for changes in last update.

If you have any idea about have to solve it, i’ll apreciate it.

Thanks in advanced.

I have a card with an input select every day of the week for selecting the zone for the vacuum to cleanup automaticly.

i have a script with the coordinate of every zone:

  alias: Salle à manger
  icon: mdi:table-chair
  - data:
      command: app_zoned_clean
      - - 23081
        - 20668
        - 28131
        - 27218
        - 1
    entity_id: vacuum.xiaomi_vacuum_cleaner
    service: vacuum.send_command
  alias: Cuisine
  icon: mdi:fridge-outline
  - data:
      command: app_zoned_clean
      - - 21121
        - 16117
        - 26121
        - 20867
        - 1
    entity_id: vacuum.xiaomi_vacuum_cleaner
    service: vacuum.send_command
  alias: Couloir
  icon: mdi:shoe-formal
  - data:
      command: app_zoned_clean
      - - 25749
        - 16115
        - 30799
        - 20265
        - 1
    entity_id: vacuum.xiaomi_vacuum_cleaner
    service: vacuum.send_command

And i have an automatisation for launching the select script of the day:

- id: '1594723468692'
  alias: Aspirateur
  description: ''
  - platform: template
    value_template: '{{ states(''sensor.time'') == states(''input_datetime.heure_passage_aspirateur'')[0:5]
  - condition: state
    entity_id: sensor.aspi_day
    state: 'True'
  - value_template:  >
       {% set sensor_names = [ 'monday', 'tuesday', 'wednesday','thursday','friday','saturday','sunday'] %}
       {% set today_name = sensor_names[now().weekday()] %}
       {% set entitid = 'input_boolean.arr_bambou_'+today_name %}
  - data:
    alias: {{ states.entitid.state }}
    service: script.turn_on  

The problème i have is that i can’t manage to get the value in the inputselect (the name of the script) to launch the script.
Can someone please help me?

Hi Damian

Works like a charm.
I want to replace the zone params with room numbers.
Any idea how to do that?

Note that syntax has changed slightly in python script…‘xiaomi_miio’, ‘vacuum_clean_zone’, args)

@GGeudens I also wanted to use room numbers and that means changing to segments instead of zones.
In the python change to:
args = {“entity_id”: “vacuum.entity”, “segments”:[]}
args[“segments”].extend([ROOM_NUMBER])‘xiaomi_miio’, ‘vacuum_clean_segment’, args)