Roborock room cleaning

Hi!
I’m using latest 2023.7.0 and I’m trying to make a simple script to clean one room.
I followed this guide and everything worked as expected except the repeat option that is not working, no matter what I choose ( 1, 2 or 3 ) it only vacuum/mop once.

This is my script:

alias: Limpar quarto principal
sequence:
  - service: vacuum.send_command
    data:
      command: app_segment_clean
      params:
        - segments:
            - 19
        - repeat: 3
    target:
      entity_id: vacuum.roborock_s7
mode: single
icon: mdi:robot-vacuum

The repeat function in the automation as I understand it is used for cross hatch cleaning of the same room, and I understand it the levels are as follows:

Repeat 1: Back and forth in one direction
Repeat 2: Back and forth and back in the perpendicular path as well
Repeat 3: It goes over the room again.

Here is a good thread on the topic. Repeats with Roborock

If you want it to run more than once with the same pattern then call your script at 2 different times.

I understand what it does, the problem is that no matter the value I put on repeat, it always do only 1 clean, no perpendicular and no repeat.

I already tried:

- repeat: 2

And:

- repeat: “2”

But it makes no difference.

Here is my automation and it works:

alias: Vacuum-Vacuum Common Areas Everyday
description: ""
trigger:
  - platform: time
    at: "09:00:00"
    enabled: true
condition: []
action:
  - choose:
      - conditions: []
        sequence:
          - service: vacuum.send_command
            data:
              command: set_water_box_custom_mode
              params: 200
            target:
              entity_id: vacuum.roborock_s7
          - service: vacuum.set_fan_speed
            data:
              fan_speed: balanced
            target:
              entity_id: vacuum.roborock_s7
          - service: vacuum.send_command
            data:
              command: app_segment_clean
              params:
                - segments:
                    - 24
                    - 25
                    - 18
                    - 19
                    - 16
                    - 22
                    - 17
                  repeat: 2
            target:
              entity_id: vacuum.roborock_s7
          - service: notify.mobile_app_XXX
            data:
              message: Everyday Vacuuming has started
              title: SUCCESS!!
          - service: notify.mobile_app_YYY
            data:
              message: Everyday Vacuuming has started
              title: SUCCESS!!
mode: single

Thanks, I added to my automations to see if it makes any difference instead of using scripts.

But I already found a difference, you are not using a dash before the command and I am, because it’s what is on the guide :confused:

data:
              command: app_segment_clean
              params:
                - segments:
                    - 24
                    - 25
                    - 18
                    - 19
                    - 16
                    - 22
                    - 17
                  repeat: 2
data:
      command: app_segment_clean
      params:
        - segments:
            - 19
        - repeat: 3

I’ll report tomorrow if it worked or not, now it’s too late to test it :sleeping_bed:

1 Like

That’s why you should always post your config when asking questions.

That dash is very important in YAML: it indicates an item in a list. What you did before is to put repeat with segments in a list instead of on its own.

Thanks, but I posted on a the first post. But I didn’t know that. TIL :ok_hand:t3:
My kid is still sleeping no chance to test it yet

Yes, I can confirm that was the dash before the repeat that was breaking the script.

1 Like

I am trying to create a button that will start cleaning in selected rooms. The rooms are selected based on toggles that I have created for individual rooms.

The problem I am facing is how to template the list of segments/rooms while calling the service. I have been fighting with that for several hours but can’t make it work:(

If I call the service from the below code in Developer tools it works but I cannot save the card as is. I need to add - segments: > but then the service doesn’t work.

Can anyone please help?

      - type: custom:mushroom-chips-card
        chips:
          - type: template
            entity: vacuum.roborock_s7_2
            tap_action:
              action: call-service
              service: vacuum.send_command
              data:
                command: app_segment_clean
                params:
                  - segments:
                      {% if is_state('input_boolean.vacuum_bedroom', 'on') %}
                        - 19
                      {% else %} {% endif %}
                      {% if is_state('input_boolean.vacuum_bathroom', 'on') %}
                        - 24
                      {% else %} {% endif %}
                    repeat: 2
              target:
                entity_id: vacuum.roborock_s7_2
            icon: mdi:playlist-play
            card_mod:
              style: |
                ha-card {
                  justify-content: center;
                }

As far as I understood there is no way to create a list with a template inside the card. I ended up creating a script and calling that from the card.

can you post your script please - I’m trying to do the same thing. Many thanks

@Neep Here you go. You need to get your own [room IDs].

alias: Vacuum Selected Rooms
sequence:
  - service: vacuum.send_command
    data:
      command: app_segment_clean
      params:
        - segments: >-
            {%- set ns = namespace(ids=[]) %} {%- if
            is_state('input_boolean.vacuum_bathroom', 'on') %}
              {% set ns.ids = ns.ids + [24] %}
            {%- endif %} {%- if is_state('input_boolean.vacuum_bedroom', 'on')
            %}
              {% set ns.ids = ns.ids + [19] %}
            {%- endif %} {%- if is_state('input_boolean.vacuum_hallway', 'on')
            %}
              {% set ns.ids = ns.ids + [16] %}
            {%- endif %} {%- if is_state('input_boolean.vacuum_kitchen', 'on')
            %}
              {% set ns.ids = ns.ids + [22] %}
            {%- endif %} {%- if is_state('input_boolean.vacuum_living_room',
            'on') %}
              {% set ns.ids = ns.ids + [23] %}
            {%- endif %} {%- if is_state('input_boolean.vacuum_technical', 'on')
            %}
              {% set ns.ids = ns.ids + [18] %}
            {%- endif %} {%- if is_state('input_boolean.vacuum_toilet', 'on') %}
              {% set ns.ids = ns.ids + [17] %}
            {%- endif %} {%- if is_state('input_boolean.vacuum_room',
            'on') %}
              {% set ns.ids = ns.ids + [20] %}
            {%- endif %} {{ ns.ids }}
          repeat: "{{ states('input_number.vacuum_repeat_count') | int }}"
    target:
      entity_id: vacuum.roborock_s7_2
mode: single
icon: mdi:robot-vacuum```
3 Likes

hero - thank you