
Part 5: Roborock S7: Sequentially Vacuuming Rooms in Home Assistant
In this guide, I'm going to show you how to create an automation that will sequentially (asynchronously) vacuum rooms in Home Assistant.
If you've been following along with my Roborock S7 Series, then you'll know I created individual scripts that correspond to each room of my house.
- script.vacuum_office
- script.vacuum_kitchen
- script.vacuum_living_room
- etc
Roborock S7 Vacuum in Home Assistant Series
In case you are finding this guide from a Google search, you may want to revisit the previous guides I've created.
- Part 1: https://smarthomepursuits.com/how-to-setup-configure-roborock-s7-with-home-assistant/
- Part 2: https://smarthomepursuits.com/roborock-s7-home-assistant-customize-map-card-create-zone-automations/
- Part 3: https://smarthomepursuits.com/roborock-s7-home-assistant-automations-schedules-and-voice-commands/
- Part 4: https://smarthomepursuits.com/roborock-s7-mop-control-in-home-assistant/
- Part 6: Vacuum & Mop Card: https://smarthomepursuits.com/clean-vacuum-mop-card-home-assistant/
Why create scripts for each room?
I did this for a number of reasons.
- It allows me to create an input_select in Lovelace that lets me choose a specific room to vacuum.
- I can expose these scripts to Google Assistant so I can trigger room vacuuming using my voice.
- Duplicated this setup to control Roborock S7 mopping in Home Assistant.
- It allows for greater flexibility in automations. (i.e. - schedule vacuuming of the Office, Kitchen, Living Room on Tuesdays, and the 3 bedrooms on Thursdays.)
I have 11 rooms in my house, so I have 11 scripts that look like this, each with different coordinates.
alias: 'Vacuum: Kitchen' sequence: - service: xiaomi_miio.vacuum_clean_zone target: entity_id: vacuum.roborock_vacuum_a15 data: zone: - - 29609 - 17748 - 34877 - 24460 repeats: 1 mode: single icon: mdi:countertop-outline
You may or may not be aware of this, but you can actually schedule up to 5 rooms to be vacuumed in a single script. The 5-room maximum is a Roborock limitation, so if you have a different robot vacuum that may not apply to you.
That script would look like this. Each double-dash indicates a new room.
alias: 'Rosie: Vacuum 3 Zones' sequence: - service: xiaomi_miio.vacuum_clean_zone target: entity_id: vacuum.roborock_vacuum_a15 data: repeats: 1 zone: - - 22474 - 25558 - 23025 - 26115 - - 23877 - 25073 - 24428 - 25630 - - 22474 - 25558 - 23025 - 26115 mode: single
However, like I said, I have 11 rooms, so that solution won't work for me. Ideally I would like to vacuum 7 "main rooms" on a schedule. (I don't schedule vacuuming in the kids bedrooms, because, well, there's always stuff on the floor.)
The solution? Create an automation that sequentially calls each room script.
This allows you to choose the order in which rooms are vacuumed, and allows you to schedule as many room cleanings as you want!
Automation #1: Vacuum Multiple Rooms by calling multiple scripts
Note: I recommend using Automation #2 instead of this one.
Originally, I had used the script below which DOES work perfectly. Basically, in the rooms:
variable, you add the ending names of your scripts. In the service call, it loops through to the next one.
The automation will start running at 2:00pm, and vacuum the office first, then the dining room, kitchen, and finally the living room. It works by looking for the state of my vacuuming - which changes from "Cleaning" to "Returning" after a zone cleanup is complete.
Create Input Boolean
First, go to Configuration > Automations & Scenes > Helpers. Click Add Helper > Toggle. Name it "Home".
This creates an input_boolean.home
entity.
Then, we add this as a condition to the automation. The reason we are doing this is so we can quickly toggle the automation on or off if we are home. For example, if you go on vacation and don't want it running like normal, just toggle this off.
alias: Vacuum Multiple Rooms description: '' trigger: - platform: time at: '14:00:00' condition: - condition: state entity_id: input_boolean.home state: 'on' action: action: - variables: rooms: - 'office' - 'dining_room' - 'kitchen' - 'living_room' - repeat: count: '{{ rooms | count }}' sequence: - service: 'script.vacuum_{{ rooms[repeat.index - 1] }}' - wait_for_trigger: - platform: state entity_id: vacuum.roborock_vacuum_a15 to: 'returning' mode: single
However, one problem I ran into with that script is in regards to the vacuum battery level. If the battery level reaches 20%, it returns to the dock automatically to recharge. However, because the code above is looking for the state of "returning", it still processes the next script (even though it won't actually vacuum it).
As an example, let's say I had 7 rooms added to the automation above. If it's vacuuming the office (4th room out of 7) and the battery level reaches 20%, it tries to return home but the automation tells it to go to room 5, 6 and then 7. This confuses the vacuum and sort of gets it caught in a weird loop.
So, you are welcome to use the automation above, but I wanted to make sure you were aware of that caveat.
Automation #2: Vacuum multiple rooms, but check for battery level
A better solution would be to check for the battery level before processing the next script, which is exactly what I have below. I added a condition:
that checks if the battery level is above 20%. If it is, it runs the next-in-line script. If it's less than 20, it doesn't and the vacuum returns home successfully to recharge.
alias: Vacuum Multiple Rooms Based if battery is greater than 20% trigger: - platform: time at: '14:00:00' condition: - condition: state entity_id: input_boolean.home state: 'on' action: - variables: rooms: - 'office' - 'kitchen' - 'dining_room' - 'living_room' - 'breakfast_room' - 'master_bedroom' - repeat: while: - condition: template value_template: >- {{ repeat.index <= rooms|count and state_attr('vacuum.roborock_vacuum_a15','battery_level')|int(0) > 20 }} sequence: - service: script.vacuum_{{ rooms[repeat.index - 1] }} - wait_for_trigger: - platform: state entity_id: vacuum.roborock_vacuum_a15 to: returning mode: single
Wrapping Up
Hopefully you found this guide as useful as I did! This was the last piece of the puzzle for me. I can now schedule groups of rooms to be vacuumed on a specific days automatically.

