What I do is a bit different but could be used for what you are thinking. I created a JSON file from the imported map, it 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"
}
]
}
I use a template REST sensor to read that JSON file into a sensor called sensor.roborock_rooms
.
##
## Roborock Rooms
##
- platform: rest
name: roborock_rooms
resource: http://192.168.2.245:8123/local/Roborock/roborock.json
value_template: "{{ now() }}"
json_attributes:
- rooms
My GUI has several buttons which I can push to create a list of the segments in a script and a button to trigger that vacuum script. The script among other things does at least this:
sequence:
- service: xiaomi_miio.vacuum_clean_segment
data_template:
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 }}
target:
entity_id: vacuum.roborock_vacuum_a15
mode: single
icon: mdi:robot-vacuum
This builds a list of “rooms” by id for the segment vacuum. A trace would look like this:
Executed: December 26, 2022 at 2:19:41 PM
Result:
params:
domain: xiaomi_miio
service: vacuum_clean_segment
service_data:
segments:
- '17'
- '16'
entity_id:
- vacuum.roborock_vacuum_a15
target:
entity_id:
- vacuum.roborock_vacuum_a15
running_script: false
limit: 10
You could easily add to the script do some notifications but I do not think you can tell if you go from the first segment to the second if that is what you want. It might be possible to send the command to clean a segment one at a time and monitor the status if it is returning to the base, if there are still more segments then stop and send the next clean segment. Not sure. Seems like a lot of work. I can check later as maybe there is a state change when moving between segments.