Indentation and a missing “|” … this allows me to save:
alias: Run Vacuum
sequence:
- service: vacuum.send_command
data_template:
command: app_segment_clean
params:
- segments: |
{%- for rooms in state_attr('sensor.roborock_rooms','rooms') -%}
{% if is_state(rooms.boolean,'on') %}
- {{ rooms.id }}
{%- endif %}
{%- endfor %}
target:
entity_id: vacuum.roborock_q_revo
mode: single
icon: mdi:robot-vacuum
I posted that originally against your old code with data, I just changed to data_template. Be sure you use what I just updated.
I would note that I hate using a loop like this outputting the way it does but others have showed it works in their examples. I much more like it like my original which does output a list. I just think something was missing in that I did not notice (indenting, data v data_template, etc.). This in reality outputs a series of strings and I never understood that.
OK, after some time and tests and poking through the code, I see the issue and the solution. The template I wrote that iterates through the room_id’s would build a list like this:
- '16'
- '17'
While the integration I use can handle “strings” as room_ids, the standard Roborock integration cannot. It requires this:
- 16
- 17
The solution is simple and this is tested on my S7 and functions using the send_command. You will note the only difference is adding the | int filter when setting the value of the variable room as in:
{% set room = rooms.id | int %}
My complete, functional script for my vacuum is:
alias: Run Vacuum Test
sequence:
- service: vacuum.send_command
data_template:
command: app_segment_clean
params:
- segments: |
{% set vacrooms = namespace(roomid=[]) %}
{% for rooms in state_attr('sensor.roborock_rooms','rooms') -%}
{% if is_state(rooms.boolean,'on') %}
{% set room = rooms.id | int %}
{% set vacrooms.roomid = vacrooms.roomid + [room] %}
{% endif %}
{%- endfor %}
{{ vacrooms.roomid }}
target:
entity_id: vacuum.roborock_s7
mode: single
icon: mdi:robot-vacuum
Just change to your entity for your Revo and it should work.
Just a note, how I diagnosed is that I duplicated my working script and changed it to use vacuum.send_command. I ran that script and just like you nothing happened. I went and ran my script and the vacuum ran as intended. I then compared the two traces for what was being sent and they were the same. After some poking into the raw code I could see that my integration did internal conversion to int which the other assumed an int. I added the int filter and voila, the vacuum happily ran.
I note that the example shown here shows that they are int values:
So I just realized I may not have posted back here but I did solve the problem. It just wasn’t intuitive, and someone pointed me in the right direction. See example below. The key piece was setting the mob intensity to off “select.roborock_q_revo_bed_mop_intensity”
Hi,
Could you please elaborate on how the camera was created and how you tset this up exactly? I have the qrevo but am struggling enormously with the xiaomi-lovelace-card
I’ve also been wondering how people are getting the room IDs. I have the Q Revo, and when I go to services, roborock.get_maps is not an available action type… Map loads nicely on my main screen, but no details about specific room IDs.