Roborock: Start program, get current coordinates, set mode-options on start

Hi folks,

I’m super happy about the awesome Roborock integration. We can now tell Alexa that “there is a sandpit in the hall” or “we made a mess” and the corresponding rooms are vacuumed. :grin:

Still, I have some requests for the Roborock integration to make it even more awesome:

  • in the app you can predefine programs incl. A subset of rooms to clean and which mode options to use. It would be great if I could trigger those from HA.

  • Navigating the robot to specific coordinates is already possible. But there does not seem to be a way to ask the robot for its current coordinates. That’d be super helpful.

  • When starting to clean or starting a segment cleaning, there should be a way to specify the mode (vacume, mob, both) and the according parameters (intensity,…).

Big thanks in advance for considering my suggestions. Let me know if I can sponsor some coffee/beer to appreciate your work!

Best
Toby

I have not looked into all of what you ask, but I already do cleaning subset of rooms and I would think using the Map sensor you can get:

vacuum_position:
  x: 25610
  'y': 25162
  a: -88

Which is an attribute hanging off the map.

For instance this is my GUI:

I can select one or more rooms and start clean of only those. I don;t do per room mop/don’t mop as I prefer to do either mopping or none (as in I remove the mop and water tank for vacuum only operations and then put them in for mopping)… I have other things set up like holding down the “Water Level” sensor will cause the vacuum to go to the kitchen sink for refill.

I am sure there are better ways but when I set this up, you could not really get room names and their ID. I thik that exists now and how I did it could be replaced. But as for now, I have a simple JSON read via REST that looks like this:

{
    "rooms": [
        {
            "name": "kitchen",
            "boolean": "input_boolean.vac_kitchen",
            "id": "17"
            },
        {
            "name": "dining_room",
            "boolean": "input_boolean.vac_dining_room",
            "id": "16"
            },
        {
            "name": "foyer",
            "boolean": "input_boolean.vac_foyer",
            "id": "18"
            },
        {
            "name": "laundry",
            "boolean": "input_boolean.vac_laundry",
            "id": "20"
            },
        {
            "name": "living_room",
            "boolean": "input_boolean.vac_living_room",
            "id": "19"
            },
        {
            "name": "master_bedroom",
            "boolean": "input_boolean.vac_master_bedroom",
            "id": "21"
            },
        {
            "name": "master_bathroom",
            "boolean": "input_boolean.vac_master_bathroom",
            "id": "22"
            },
        {
            "name": "guest_bathroom",
            "boolean": "input_boolean.vac_guest_bathroom",
            "id": "23"
            }
    ],
    "points": [
        {
            "name": "sink",
            "x": 17989,
            "y": 25491
         }
    ]
}

SO the input booleans in the GUI across the top are clicked and script is like this:

run_vacuum:
  alias: Run Vacuum
  sequence:
  - service: roborock.vacuum_clean_segment
    data_template:
      segments: "{% set vacrooms = namespace(roomid=[]) %}\n{% for rooms in state_attr('sensor.roborock_rooms','rooms')
        -%}\n  {% if is_state(rooms.boolean,'on') %}\n    {% set room = rooms.id %}\n
        \   {% set vacrooms.roomid = vacrooms.roomid + [room] %}\n  {% endif %}\n{%-
        endfor %}\n{{ vacrooms.roomid }}\n"
    target:
      entity_id: vacuum.roborock_s7
  mode: single
  icon: mdi:robot-vacuum

So for each input_boolean that is “on” (aka Kitchen and Dining in the screen shot), it will clean them.

1 Like

Hi!

Thanks for the insights! I don’t have a “map” sensor in my HA. Did you do anything special to get that?

These are all the sensors I have from Roborock:

Cheers
Toby

I use this integration GitHub - humbertogontijo/homeassistant-roborock: Roborock integration for Home Assistant. This integration uses your devices from the Roborock App

Perhaps you have a different one?

Ah, yes, I use the official one: Roborock - Home Assistant. That’s also why I posted the feature requests here. :slightly_smiling_face:

Well you can still do multiple map segments as that integration has that sample right in the description. You run a command to get id’s. I would examine all the other attributes off those sensors as maybe one has current position

Yes, I can replicate the programs from the app in HA, that is true.

I spent this AM redoing mine for Kiosk mode.

Going to add some animations and such.

1 Like

Looks great. The official integration says to also aim for map features. Hope we get there, soon. :slight_smile:

@tobyS @kbrown01 any news here? It is 2023 now and I still do not see much progress in the “default” roborock integration.
Should I switch to the XIOAMI integration - and if I do so, could I use them in parallel?
Because I really like the Roborock-App…

This is my setup;

quite simple, but extremly effective;

Modus: vacuum & mop, vacuum, mop, intesive (will first vacuum and mop @ full power, than, when it returns to dock, it will switch to vacuum only, and do the same room again).

Ruimte: i’ll select the zone to clean. I’ve got also a zone at the dining table where our kids are.

i cant get it to work im trying to achive this with bools im using the official roborock integration

i tryed this:

service: vacuum.send_command
data:
  command: app_segment_clean
  params:
    - segments:
        "{% if states('input_boolean.cuarto_tv') == 'on' %}- 18{% endif %}"
        "{% if states('input_boolean.cocina') == 'on' %}- 20{% endif %}"
target:
  entity_id: vacuum.s7_roborock


with no luck also this

data:
  command: app_segment_clean
  params:
    - segments: >-
        {% if states('input_boolean.cuarto_tv') == 'on' %}- 18{% endif %}
        {% if states('input_boolean.cocina') == 'on' %}- 20{% endif %}
target:
  entity_id: vacuum.s7_roborock

type or paste code here

and this, im pretty sure its syntax issue

service: vacuum.send_command
data:
  command: app_segment_clean
  params:
    - segments: |
        {% if states('input_boolean.cuarto_tv') == 'on' %}- 18{% endif %}
        {% if states('input_boolean.cocina') == 'on' %}- 20{% endif %}
target:
  entity_id: vacuum.s7_roborock

but i dont know where. any help thank you
> Blockquote

Blockquote

IMHO, that would never work as you are merely returning strings from the template. You need to build a list. In my case, I use a REST sensor that contains all the rooms. I have a JSON file that maps boolean name/id and friendly name.

{
    "rooms": [
        {
            "name": "kitchen",
            "boolean": "input_boolean.vac_kitchen",
            "id": "17"
            },
        {
            "name": "dining_room",
            "boolean": "input_boolean.vac_dining_room",
            "id": "16"
            },
        {
            "name": "foyer",
            "boolean": "input_boolean.vac_foyer",
            "id": "18"
            },
        {
            "name": "laundry",
            "boolean": "input_boolean.vac_laundry",
            "id": "20"
            },
        {
            "name": "living_room",
            "boolean": "input_boolean.vac_living_room",
            "id": "19"
            },
        {
            "name": "master_bedroom",
            "boolean": "input_boolean.vac_master_bedroom",
            "id": "21"
            },
        {
            "name": "master_bathroom",
            "boolean": "input_boolean.vac_master_bathroom",
            "id": "22"
            },
        {
            "name": "guest_bathroom",
            "boolean": "input_boolean.vac_guest_bathroom",
            "id": "23"
            }
    ],
    "points": [
        {
            "name": "sink",
            "x": 17989,
            "y": 25491
         }
    ]
}

Then a sensor that reads that JSON from my installation. Note I use multiple YAML file includes so this would be in configuration.yaml as:

sensor: !include sensor.yaml

Then in sensor.yaml I have this:

##
## Roborock Rooms 
##
- platform: rest
  name: roborock_rooms
  resource: http://192.168.1.245:8123/local/Roborock/roborock.json
  value_template: "{{ now() }}"
  json_attributes:
    - rooms
    - points

Then I can build a list from the booleans that are “on” as follows:

      segments: |
        {% set vacrooms = namespace(roomid=[]) %}
        {% for rooms in state_attr('sensor.roborock_rooms','rooms') -%}
          {% if is_state(rooms.boolean,'on') %}
            {% set room = rooms.id %}
            {% set vacrooms.roomid = vacrooms.roomid + [room] %}
          {% endif %}
        {%- endfor %}
        {{ vacrooms.roomid }}

There are many ways to do it … no JSON, just fields. You could do it using a similar namespace and a series of if’s if you like, but it needs to be a list. The top left off the image are the input_boolean’s for all the rooms. I can select several rooms and run:

Just an updated note for anyone stumbling across this, it turns out that because the particular integration i use, the segments could be like this (strings) as it does string to integer conversion inside the integration.

- '16'
- '17'

At least one (the now main Roborock integration) does not support strings and they must be integers like:

- 16
- 17

So the code should change from:

{% set room = rooms.id %}

to:

{% set room = rooms.id | int %}

This way the list of room IDs are integers. There is a long thread here which leads to this:

1 Like

Hi, how do you navigate the robot to a specific coordinate? I would love to be able to click a button and have the vacuum go to the bin.

1 Like

Can you please share the whole configuration for mushroom card of vacuum. I am stuck after rest sensor

I just setup an automation to send the vacuum to the dustbin with the service call below.

I got the coordinates by trail-and-error. I found online that 25500,25500 is the location of the dock and tweaked from there. I just changed the numbers until the vacuum ended up where I wanted it. I started with steps of 100, but those were kind of small, 500 or 1000 steps was more useful. The vacuum seems to ignore targets it can’t reach, so seems unlikely to break things with too big values.

First number is left/right as seen on the Home Assistant map (the map in the Roborock App is rotated for me). The second number is up/down or down/up not sure as I needed it to be on the same level as the dock, but should be easy to figure out.

service: vacuum.send_command
target:
  entity_id: vacuum.roborock_s7
data:
  params:
    - 18500
    - 25500
  command: app_goto_target

Everyone trying to send Roborock to a point that you can find the coordinates for and create an automation to make it a clickable thing or do some cleaning through Home assistant, by having essentially permanent zones. Watch this video https://youtu.be/-UXL4a_fmOc?si=kWPf8y2AAU-YPDw9

I followed what he did and was able to find the coordinates of any area for a zone by doing the debug he shows. 10/10 recommend.

Thank you for sharing this super low tech way to determine points on the map. After looking at other tutorials that were much fancier solutions, this trial and error approach worked perfect.

I use the official roborock integration, and whenever I called this service, the “Go to Target” page on the app would drop a pin.

1 Like