Part 2: Roborock S7 Home Assistant: Customize Map Card & Create Zone Automations

Part 2: Roborock S7 Home Assistant: Customize Map Card & Create Zone Automations

In this guide, I'll show you how to add some quality-of-life improvements to your Roborock S7 integration in Home Assistant.

In Part 1, I’ve shown you how to:

  • Unbox and setup your Roborock S7 vacuum cleaner
  • Connect it to your MiHome App
  • Extract the cloud token
  • Add Roborock S7 integration to Home Assistant
  • Create a few Lovelace cards to manage your vacuum

In Part 2 (this guide), I’ll showed you how to:

  • Create clickable zones on your Vacuum Map Card
  • Add text room names to your Vacuum Map Card
  • Select rooms from a Lovelace dropcard to schedule individual room cleanings

In Part 3, I’ll show you how to:

  • Create automations & notifications
  • Clean rooms or zones on a schedule
  • Create Google Assistant voice commands to clean zones or rooms

In Part 4, I'll show you:

  • How to control the roborock s7 mop in Home Assistant

In Part 5, I'll show you:

  • How to vacuum multiple rooms in an automation (by calling each script.vacuum_xyz script). This allows you to select the order and schedule vacuuming for as many rooms as you'd like.

In Part 6, I'll show you:

  • A compact, simple vacuum & mop control card

Let's get started!


Overview

With the Vacuum Map Card, you can already instruct your vacuum to go to a certain point (Pin & Go) and also drag over an area of your house to have it clean a specific zone (zone cleanup).

We are going to take it a step further and define actual zones. This will let you click a specific room on the map card and tell your vacuum to clean just that room without having to drag it over the area.

Once the zones/points are defined, we are going to add that to an input select helper. We can then add that to an entities card, so in a dropdown, you can choose a room, and then click Start Cleaning.


Step 1: Get coordinates for a specific location

Before we define a specific zone (or a room), we are going to get the coordinates for a certain point. A point might be your trash can or your sink. These points will instruct your vacuum to go directly there.

On your card, choose Pin & Go. Drop the pin at a specific location.

Then, click and hold the Play button. A box will popup displaying the coordinates of that predefined location in X and Y coordinates

Copy the value to clipboard for quick reference and paste in Notepad. Format it is .

37651,18940

Do this for as many points as you want. It may help to add a label to Notepad so you remember which coordinates are which.


Step 3: Get Coordinates for Zone

Next, switch from Pin & Go to Zone cleanup. Click the "+" button and then move the zone over a specific room.

Click and hold the Play button like before. This time, it'll show 4 coordinates.

Copy and paste those to your Notepad file as well:

[22023,23769,26332,27671]

Define as many zones as you want:


Step 5: Add Permanent Zones & Points to Map Card

Now that you have defined boundaries for your zones, we can add those as permanent zones to the card itself. (zones:) We will also add the points to the map (position:)

This will let you click the Office for example, and it'll automatically start cleaning there. No more needing to manually drag over that area each time.

To do this, edit your existing map card.

Then, add zones and points to your card like this:

Here's the yaml for my card - you can copy and paste this into a Manual card and just change entity name and coordinates.

type: custom:xiaomi-vacuum-map-card entity: vacuum.roborock_vacuum_a15 map_source: camera: camera.xiaomi_cloud_map_extractor calibration_source: camera: true vacuum_platform: default title: Roborock S7 map_modes: - template: vacuum_clean_zone - template: vacuum_goto - template: vacuum_goto_predefined predefined_selections: - position: - 37651 - 18940 - position: - 33531 - 19508 - template: vacuum_clean_zone_predefined predefined_selections: - zones: - - 22023 - 23769 - 26332 - 27671 - zones: - - 26285 - 22065 - 29741 - 27577 - zones: - - 23348 - 21970 - 29741 - 23694 - template: vacuum_follow_path


Step 6: (Optional) Adding Names to Zones

If you would like names or icons to appear on your Zone list and Points, here's what you'd do.

Add Name & Icon to Points

For points, add the following code under each points. Where X and Y are the same as what you used in the position.

 label: text: Trash x: 37651 'y': 18940 offset_y: 35 icon: name: mdi:trash-can x: 37651 'y': 18940

Add Text to Zones

For zones, since there are 4 coordinates of the bounding box, you can't use the X,Y,X,Y values you've already grabbed, as those are for the 4 corners.

Instead, click Pin & Go on the map and click and hold the play button get the coordinates of the middle of the room.

It will now look like this:

Full Example YAML for points, zones, icons, and text overlays for each zone.

type: custom:xiaomi-vacuum-map-card entity: vacuum.roborock_vacuum_a15 map_source: camera: camera.xiaomi_cloud_map_extractor calibration_source: camera: true vacuum_platform: default title: Roborock S7 map_modes: - template: vacuum_clean_zone - template: vacuum_goto - template: vacuum_goto_predefined predefined_selections: - position: - 37651 - 18940 icon: name: mdi:trash-can x: 37651 'y': 18940 - position: - 33531 - 19508 icon: name: mdi:water x: 33531 'y': 19508 - template: vacuum_clean_zone_predefined predefined_selections: - zones: - - 22023 - 23769 - 26332 - 27671 label: text: Office x: 24012 'y': 25523 - zones: - - 26285 - 22065 - 29741 - 27577 label: text: Dining Room x: 27942 'y': 25807 - zones: - - 23348 - 21970 - 29741 - 23694 label: text: Entry x: 24627 'y': 22965 - template: vacuum_follow_path

Step 7: Create Input Select for each Zone

Now that you've got your Vacuum Map Card customized to your liking, we are going to create an input_select. This will give you a dropdown list of zones you can click to start cleaning. This is also optional, but it's nice to simply view the name of a room and tell it to start cleaning there rather than having to find it on the map card.

Here's what that looks like:

Configuration > Automations & Scenes > Helpers. Then click Add Helper > Dropdown.

Give your dropdown a name like "Vacuum Rooms", and then add as many rooms as you'd like to be able to point-and-click to vacuum or go to. I added parenthesis to specific points so they are quicker to find.

Your entity name is now called:

input_select.vacuum_rooms


Step 8: Create Scripts

Next, we need to create individual scripts to call for each option we added to the input select. In my example, I'll need to create 5 scripts.

Configuration > Automations & Scenes > Scripts.

Note: We will be creating two different types of scripts: one for a specific point and one for a zone.

Tip: After completing 1 script for a point and 1 for zone, just duplicate it and change the Name, entity name, and coordinates:


Script to Go To Specific Point

Create a new script like my screenshot below or copy my YAML and just change out the coordinates with your own.

The target is your vacuum (Rosie) and the parameters are the X and Y coordinates of the point. This will tell the vacuum to go that specific point and stop; it won't tell it to vacuum there.

Repeat this process for as many points as you have.

Zone cleanup parameters look like this:

 params: - - 37651 - 18940

Specific point cleanup parameters look like this:

 params: - 37651 - 18940
alias: 'Vacuum: Trash Can' sequence: - service: vacuum.send_command target: entity_id: vacuum.roborock_vacuum_a15 data: command: app_goto_target params: - 37651 - 18940 mode: single icon: mdi:trash-can

Script to Vacuum Zone

Create a new script like my screenshot below. Instead of going to a point, we are using the service xiaomi_miio.vacuum_clean_zone.

Add the 4 coordinates for that zone. Set the number of repeats to 1.

Repeat this process for as many zones as you have.

alias: 'Vacuum: Office' sequence: - service: xiaomi_miio.vacuum_clean_zone target: entity_id: vacuum.roborock_vacuum_a15 data: repeats: 1 zone: - - 22023 - 23769 - 26332 - 27671 mode: single icon: mdi:desktop-classic


Step 9: Create Automation to call each script when triggered from input select

Go to Automations > Add Automation. Start with an empty automation. Go into the YAML editor of the automation and paste in the code below.

Under the data_template section, change the Input Select name (input_select.vacuum_rooms) you created in Step 7 and match it up with the corresponding script you created in Step 8.

We are adding a Stop command and 3 second wait timer to this automation. The reason I'm doing this is because you can't stop a script once it's already been triggered from input_select. For example, if you accidentally click Office but meant to tell your roborock to go to dining room, it won't listen.

alias: Run Vacuum Zone description: '' trigger: [] condition: [] action: - service: vacuum.stop target: entity_id: vacuum.roborock_vacuum_a15 - delay: hours: 0 minutes: 0 seconds: 3 milliseconds: 0 - service: script.turn_on data_template: entity_id: > {% if states.input_select.vacuum_rooms.state == "Office" %} script.vacuum_office {% elif states.input_select.vacuum_rooms.state == "Dining Room" %} script.vacuum_dining_room {% elif states.input_select.vacuum_rooms.state == "Front Entry" %} script.vacuum_front_entry {% elif states.input_select.vacuum_rooms.state == "(Trash Can)" %} script.vacuum_trash_can {% elif states.input_select.vacuum_rooms.state == "(Sink)" %} script.vacuum_sink {% endif %} mode: single


Step 10: Add Input Select to Lovelace

And lastly, we need to add the input select to Lovelace as well as a "Start Cleaning" button to trigger the zone or point we want the vacuum to go.

Once the card is added, just choose a room and click Start!

Add a Manual Card to Lovelace (Start Cleaning button)

Just change out the input_select name, automation name, and entity.

type: grid cards: - type: entities entities: - entity: input_select.vacuum_rooms - type: grid cards: - type: button tap_action: action: call-service service: automation.trigger service_data: {} target: entity_id: automation.run_vacuum_zone entity: vacuum.roborock_vacuum_a15 name: Start - type: button tap_action: action: call-service service: vacuum.stop service_data: {} target: entity_id: vacuum.roborock_vacuum_a15 name: Stop entity: vacuum.roborock_vacuum_a15 - type: button tap_action: action: call-service service: vacuum.return_to_base service_data: {} target: entity_id: vacuum.roborock_vacuum_a15 name: Return to Dock entity: vacuum.roborock_vacuum_a15 square: false columns: 1


Wrapping Up

Hopefully this guide helped you out! I wanted to give a shout out to This Smart House's Youtube channel for the inspiration.

Make sure to check out all 4 parts of my Roborock S7 series (links at the top of this guide), I'll show you how to configure Google Assistant voice commands using these scripts we've already created and learn how to create some useful scheduled cleanings and automations!

Image 1 from Part 2: Roborock S7 Home Assistant: Customize Map Card & Create Zone Automations
Image 2 from Part 2: Roborock S7 Home Assistant: Customize Map Card & Create Zone Automations
Image 3 from Part 2: Roborock S7 Home Assistant: Customize Map Card & Create Zone Automations
Image 4 from Part 2: Roborock S7 Home Assistant: Customize Map Card & Create Zone Automations
Image 5 from Part 2: Roborock S7 Home Assistant: Customize Map Card & Create Zone Automations
Image 6 from Part 2: Roborock S7 Home Assistant: Customize Map Card & Create Zone Automations
Image 7 from Part 2: Roborock S7 Home Assistant: Customize Map Card & Create Zone Automations
Image 8 from Part 2: Roborock S7 Home Assistant: Customize Map Card & Create Zone Automations
Image 9 from Part 2: Roborock S7 Home Assistant: Customize Map Card & Create Zone Automations
Image 10 from Part 2: Roborock S7 Home Assistant: Customize Map Card & Create Zone Automations
Image 11 from Part 2: Roborock S7 Home Assistant: Customize Map Card & Create Zone Automations
Image 12 from Part 2: Roborock S7 Home Assistant: Customize Map Card & Create Zone Automations
Image 13 from Part 2: Roborock S7 Home Assistant: Customize Map Card & Create Zone Automations
Image 14 from Part 2: Roborock S7 Home Assistant: Customize Map Card & Create Zone Automations
Image 15 from Part 2: Roborock S7 Home Assistant: Customize Map Card & Create Zone Automations
Image 16 from Part 2: Roborock S7 Home Assistant: Customize Map Card & Create Zone Automations
Image 17 from Part 2: Roborock S7 Home Assistant: Customize Map Card & Create Zone Automations
Image 18 from Part 2: Roborock S7 Home Assistant: Customize Map Card & Create Zone Automations
Image 19 from Part 2: Roborock S7 Home Assistant: Customize Map Card & Create Zone Automations
Image 20 from Part 2: Roborock S7 Home Assistant: Customize Map Card & Create Zone Automations
Image 21 from Part 2: Roborock S7 Home Assistant: Customize Map Card & Create Zone Automations
Image 22 from Part 2: Roborock S7 Home Assistant: Customize Map Card & Create Zone Automations
Image 23 from Part 2: Roborock S7 Home Assistant: Customize Map Card & Create Zone Automations
Image 24 from Part 2: Roborock S7 Home Assistant: Customize Map Card & Create Zone Automations
Image 25 from Part 2: Roborock S7 Home Assistant: Customize Map Card & Create Zone Automations
Image 26 from Part 2: Roborock S7 Home Assistant: Customize Map Card & Create Zone Automations
Image 27 from Part 2: Roborock S7 Home Assistant: Customize Map Card & Create Zone Automations