So basically I have only little understanding of Jinga2 and I thought some of you could help me. (If someone could make this into a template it would be great, because I think many of us could use it)
What I’m trying to achieve:
Create two scripts/services with a custom data input:
one for cleaning selected rooms (or when left empty every room)
one for mopping selected rooms (1-go to specified location to attach water tank. 2-clean selected rooms. 3-drive to selected point again to detach the water tank. 4-drive back home)
-Roborock has numbers 1-20 for detected rooms. It would be nice to give them a friendly name. (So call script with data “bedroom; kitchen” instead of “12;19”
-Sending me a actionable notification when I should attach/detach the water tank
If anyone has ideas about how to implement this please let me know.
For the first part have a look at my script. The only difference is mine is only for one room, but you can modify it to works with multiple rooms. Script have comments so I thing is easy to understand.
vacuum_clean_room:
alias: vacuum_clean_room
sequence:
- alias: Get room id using input select
variables:
# get room string from input select
target_room_selector: input_select.vacuum_target_room
# map each room number with a string with a dictionary
room_map:
Select one room: 0
Bedroom: 16
Kitchen: 17
Living room: 18
Bathroom: 20
Hall: 21
# get target room to clean
target_room: '{{ room_map[states(target_room_selector)] | int}}'
# check that one room was selected
- condition: template
value_template: '{{ target_room != 0 }}'
# call service to clean selected room
- service: xiaomi_miio.vacuum_clean_segment
data:
entity_id: vacuum.roborock_vacuum_m1s
# segments should be an array of numbers if more than one room want to be cleaned
segments: '{{ target_room }}'
And in the script check for all entities, when one is on, add it number to the array.
In last line in the “segments” you need to give the array with room numbers.
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.vacuum_floorplan_hall_selected') == 'on' %}
{% set rooms = rooms + [21] %}
{% endif %}
{% if states('input_boolean.vacuum_floorplan_kitchen_selected') == 'on' %}
{% set rooms = rooms + [17] %}
{% endif %}
{% if states('input_boolean.vacuum_floorplan_living_room_selected') == 'on' %}
{% set rooms = rooms + [18] %}
{% endif %}
{{rooms}}
# check that almost one room was selected
- condition: template
value_template: '{{ target_rooms | length > 0 }}'
# call service to clean selected rooms
- service: xiaomi_miio.vacuum_clean_segment
data:
entity_id: vacuum.roborock_vacuum_m1s
# segments should be an array of numbers if more than one room want to be cleaned
segments: '{{ target_rooms }}'