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

by Danny
0 comment

READING TIME: 11 MINUTES

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

Let’s get started!

Roborock S7 Robot Vacuum and Mop, 2500PA Suction & Sonic Mopping, Robotic Vacuum Cleaner with Multi-Level Mapping, Works with Alexa, Mop Floors and Vacuum Carpets in One Clean, Perfect for Pet Hair
  • Roborock S7 robot vacuum is the Winner of 17 Best of CES 2021 Awards, from Business Insider, Digital Trends, Newsweek, How To Geek, and many more.
  • Sonic Mopping Technology. Roborock S7 robot vacuum mops with the power of sound, scrubbing up to 3,000 times per minute. Fed by a 300 ml electronic water tank, stains from coffee to mud and more can be cleaned deeply and effectively.
  • Intelligent Mop Lifting. S7’s VibraRise mop lifts when a carpet is detected, so you can mop hard floors and vacuum carpets in a single clean. It also raises when cleaning is finished to avoid spreading dirt, and when docked so you can say goodbye to ugly plastic mats and dirty streaks.

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 [X,Y].

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 Cleaning!

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
    show_header_toggle: false
  - type: button
    tap_action:
      action: call-service
      service: automation.trigger
      service_data: {}
      target:
        entity_id: automation.run_vacuum_zone
    name: Start Cleaning
    entity: vacuum.roborock_vacuum_a15
columns: 2
square: false

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 3 parts of my Roborock S7 series, 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!


My Favorite Home Assistant Devices

Below are some of the Home Assistant-compatible devices I personally use in my home. I highly recommend each of them.

The full list of all Home Assistant compatible & recommended devices I use can be found on my Equipment List page.

Smart Home Product Finder

What hub do you currently use?


SmartThings

Home Assistant

Hubitat

Step 1 of 3

What product are you looking to add?


Lights

Locks

Thermostats

Cameras

Garage Door Opener

Switches

Sensors

Motion, Door & Window, Leak

Smart Plugs

Buttons

Step 2 of 3

What protocol?


Z-Wave

Zigbee

Wifi

Step 3 of 3

Retake quiz? Click here!

0 comment

You may also like

Leave a Comment