Roborock integration clean several specific rooms

Yeah I can see how you add multiple segments to the code if you’re hardcoding the numbers. But in my implementation I have 1 script that I call from an automation passing through the id.

I guess if I removed the “-” from the script then I can pass through the IDs like you’ve written. Might give it a go.

I see. Sorry I didn’t spot that you are trying to pass the room number into the script.

1 Like

Valetudo uses a clever script for such cases, that you could adopt. :slight_smile:

  • Setup a few input_booleans with the rooms.
    input_boolean.vacuum_hallway:
      room_id: "18"
    input_boolean.vacuum_livingroom:
      room_id: "16"
    input_boolean.vacuum_bedroom:
      room_id: "20"
    input_boolean.vacuum_kitchen:
      room_id: "17"
    input_boolean.vacuum_study:
      room_id: "19"
    
  • Setup a group with these.
    vacuum_rooms:
     name: Vacuum Rooms
     entities:
       - input_boolean.vacuum_bedroom
       - input_boolean.vacuum_hallway
       - input_boolean.vacuum_kitchen
       - input_boolean.vacuum_livingroom
       - input_boolean.vacuum_study
    
  • Use a script to check the group
    script:
      vacuum_clean_segments:
        alias: vacuum_clean_segments
        sequence:
          - service: mqtt.publish
            data:
              topic: valetudo/xxx
              payload_template: >
                {% set segments = expand("group.vacuum_rooms") | selectattr("state","eq","on") | map(attribute="attributes.vacuum_room_id") | list | to_json %}
                {% set iterations = states('input_number.vacuum_segment_iterations') | int %}
                {"segment_ids": {{ segments }}, "iterations": {{ iterations }}, "customOrder": true }
          - delay: '00:00:02'
          - service: homeassistant.turn_off
            entity_id: group.vacuum_rooms
        mode: single
    

The last one is my config which uses MQTT, but for you to get an idea on how to “expand” the group entries, it should work. :slight_smile:

The original is here on the Valetudo page:

1 Like

Why does that work:

service: vacuum.send_command
data:
  command: app_segment_clean
  params:
    
segments:
19
19
repeat: 2
target:
  entity_id: vacuum.roborock_s8_pro_ultra

and that does not work?

service: vacuum.send_command
data:
  command: app_segment_clean
  params:
    
segments:
19
  repeat: 2
target:
  entity_id: vacuum.roborock_s8_pro_ultra

This is exactly what I’m looking for but via a script not Valetudo.

Has anyone figured out a script to pass the room_id into the segements based on the input_boolean that is enabled.

Nearest I’ve got it:

vacuum_clean_room:
  alias: vacuum_clean_room
  sequence:
  - alias: Get room id using input select
    variables:
      # store room number in array if room is on
      target_rooms: >-
        {% set rooms = [] %}
        {% if states('input_boolean.hoover_corridor') == 'on' %}
            {% set rooms = rooms + [21] %}
        {% endif %}
        {% if states('input_boolean.hoover_dining_room') == 'on' %}
            {% set rooms = rooms + [20] %}
        {% endif %}
        {% if states('input_boolean.hoover_kitchen) == 'on' %}
            {% set rooms = rooms + [16] %}
        {% endif %}
        {% if states('input_boolean.hoover_living_room) == 'on' %}
            {% set rooms = rooms + [18] %}
        {% endif %}
        {% if states('input_boolean.hoover_sitting_room) == 'on' %}
            {% set rooms = rooms + [17] %}
        {% endif %}
        {% if states('input_boolean.hoover_study) == 'on' %}
            {% set rooms = rooms + [19] %}
        {% endif %}
        {{rooms}}
   # check that almost one room was selected
  - condition: template
    value_template: '{{ target_rooms | length > 0 }}'
  # call service to clean selected rooms
  - service: vacuum.send_command
    data:
      command: app_segment_clean
      params:
        - segments: '{{ target_rooms }}'
      # segments should be an array of numbers if more than one room want to be cleaned
          repeat: 1
    target:
      entity_id: vacuum.roborock_s7_pro_ultra

Can’t quite get it working though

For one thing, you are missing end quotes on many of the input_boolean’s.

{% if states('input_boolean.hoover_kitchen) == 'on' %}

Should be:

{% if states('input_boolean.hoover_kitchen') == 'on' %}

I did mine slightly different but close, see here:

You could even use the name pattern like “input_boolean.hoover*”.

I use Roborock Integration with HA via HACS and followed the above steps for selective room cleaning (Developer Tool, State, Camera.Roborock, find 2-digit Room ID, and then check which ID associates with each room). I wrote the script with UI to specify 3 rooms to clean in specific order (I.e., Hallway, Bedroom, and Bathroom) and triggered the scrip with a click on my Ikea remote. However, the robot always starts with Bedoom instead of Hallway. The same thing happens if I use Selective Room Cleaning in Roborock App and manually select the 3 rooms in such order - it always cleans Bedroom first. The only way I can achieve what I want is to define the order in Sequence option of Roborock App. When I did that the Selective Room Cleaning in both Roborock App and HA works. It should be noted that the robot charging station is located in the Bedroom and the bedroom is the largest room among the three. So, does this mean selective room cleaning with Roborock Integration in HA will never work because the order the rooms are cleaned is governed by Sequence option in Roborock App?

Could someone get the rooms in the map card using the roborock integration? I was able to make an script for cleaning an specific room with its ID, but I don’t know how to clean the specific rooms through the xiaomi map vacuum card, also trying to zone cleanup it says xiaomi_mioo/vacuum_clean_zone service not found, this can be made with the roborock integration? And last, it’s not shown the status, batterty etc.

the secuence of the cleaning room its assing in the map (the phone app)

Hi

I am trying to use your script, but I have 2 levels in my house so need to use the vacuum: send command “load_multi_map” with parameters 0 or 1 depending on which rooms I want to vacuum. 0 corresponds with the lower floor and 1 is the first floor. This ensures the vacuum loads the correct map as the room numbers are duplicated on the two different maps.
Is there a way to add into your script if certain rooms are selected, then first send command “load_multi_map” 0 or 1 depending on the rooms?

Thanks

I would just add an extra input_boolean, if it is “off” it is “0”, if it is “on”, it’s “1”.
Then change the script to call loading the correct map first.

You of course cannot pick a series of rooms that are on both floors. It would be up to you to display. But you could add the floor (“0” or “1”) in the JSON and do an automation that would disable that floors input_booleans for the rooms.

Thanks, I’ll give it a go

Fortunately for me, my house is one story so I do not have that problem and therefore not implemented. I can understand how to do it, but would be up to you to do so and test.

Hello.

Got a Q7 and was wondering how to get map information for all my maps. I got the first floor, but my second (basement) is not imported

Hello, can you explain what does correspond to:

    "points": [
        {
            "name": "sink",
            "x": 17989,
            "y": 25491
         }
    ]

THANKS

I use that with a script called on a hold action to send the vacuum to the sink to fill water and wash the mop. The script calls the service roborock.vacuum_goto

goto_point:
  alias: GoTo Point
  sequence:
  - service: roborock.vacuum_goto
    data_template:
      x_coord: '{% set pointname = "sink" %}
        {% for point in state_attr(''sensor.roborock_rooms'',''points'') -%}
        {% if point.name == pointname %}
        {{point.x}}
        {% endif %}
        {%- endfor %}
        '
      y_coord: '{% set pointname = "sink" %}
        {% for point in state_attr(''sensor.roborock_rooms'',''points'') -%}
        {% if point.name == pointname %}
        {{point.y}}
        {% endif %}
        {%- endfor %}
        '
1 Like

Thanks. I still have a problem, when I run the script.run_vacuum, I get this message that appears → Error rendering data template: TypeError: ‘None Type’ object is not iterable

do you have an idea ?

Post the code you have for:

  1. The script
  2. The REST sensor for the rooms that contain the input_boolean names

I will bet you are missing #2, do you have a local JSON file and a REST sensor that reads the room names, room id’s and input_boolean names?

Hi there, for me the GENERATE ROOMS is never available, nor that sensors/filters button, why? Can you advise?

It’s okay, I found, the .json file was bad. It works now. thank you very much for your help