Replies: 1 comment
-
I have it on my S7. I have a loop which waits for the vacuum state to go from cleaning to returning_to_dock before proceeding to send the command to e.g. mop after vacuuming or proceed ot the next room. Here is the code - vacuum_segment_by_segment:
alias: "Cleaning: Vacuum segment cleaning automation"
mode: queued
fields:
entity_id:
name: "Target"
description: "entity_id of the vacuum cleaner"
required: true
example: "vacuum.mr_bobot"
default: "vacuum.mr_bobot"
segments:
name: "Rooms to clean"
description: "list of int: List of room ids to vacuum"
required: true
example: "[12,34,56]"
repeats:
name: "Repeats"
description: "int: Number of passes vacuum will make for each room"
required: false
example: 1
default: 1
variables:
#define default cleaning scheme
vacuum_id: "{{entity_id}}"
mop_mode_select: "select.{{vacuum_id.split('.')[1]}}_mop_mode"
mop_intensity_select: "select.{{vacuum_id.split('.')[1]}}_mop_intensity"
cleaning_order: [16, 19, 17, 25, 21, 26, 23, 22, 18, 24]
roomid_to_name:
18: "bedroom"
17: "salon"
19: "jadalnia"
16: "kuchnia"
24: "shower"
21: "hall"
25: "wc"
26: "kids"
23: "bathroom"
22: "gabinet"
room_name_to_id:
kuchnia: 16
jadalnia: 19
salon: 17
wc: 25
hall: 21
kids: 26
bathroom: 23
gabinet: 22
bedroom: 18
shower: 24
fan_setting:
kuchnia: max
jadalnia: max
salon: balanced
wc: balanced
hall: max
kids: balanced
bathroom: balanced
gabinet: balanced
bedroom: balanced
shower: balanced
mop_intensity_setting:
kuchnia: intense
jadalnia: intense
salon: mild
wc: moderate
hall: intense
kids: mild
bathroom: moderate
gabinet: mild
bedroom: mild
shower: moderate
mop_mode_setting:
kuchnia: deep_plus
jadalnia: deep_plus
salon: standard
wc: deep
hall: deep_plus
kids: standard
bathroom: deep
gabinet: standard
bedroom: standard
shower: deep
max_days_since_last_cleaning_for_combined:
kuchnia: 0
jadalnia: 0
salon: 2
wc: 1
hall: 0
kids: 2
bathroom: 1
gabinet: 2
bedroom: 2
shower: 1
sequence:
- if:
- "{{not has_value(vacuum_id)}}"
then:
- wait_for_trigger:
- platform: template
value_template: "{{not is_state(vacuum_id,['unavailable','unknown'])}}"
timeout: "0:01:00"
- if:
- "{{wait.trigger == none}}"
then:
- stop: "The vacuum cleaner appears unavailable. Fix it and give a try later."
error: true
- variables:
was_fan_custom: "{{is_state_attr(vacuum_id,'fan_speed','custom')}}"
was_mop_custom: "{{is_state_attr(vacuum_id,'mop_intensity','custom')}}"
was_mop_mode_custom: "{{is_state_attr(vacuum_id,'mop_mode','custom')}}"
fan_initial: "{{state_attr(vacuum_id,'fan_speed')}}"
mop_mode_initial: "{{states(mop_mode_select)}}"
mop_intensity_initial: "{{states(mop_intensity_select)}}"
# todo: deal with interruption, global var?
- repeat:
for_each: "{{cleaning_order}}"
sequence:
# if room in room to clean, clean it
- if:
- "{{repeat.item in segments}}"
then:
- variables:
room: "{{roomid_to_name[repeat.item]}}"
combine: "{{as_timestamp(now())-as_timestamp(states('input_datetime.vacuum_last_'+room))<86400*(max_days_since_last_cleaning_for_combined[room]+1)}}" #false if now()-input_datetime > max_days
fan: "{{fan_setting[room]}}"
mop_intensity: "{{mop_intensity_setting[room]}}"
mop_mode: "{{mop_mode_setting[room]}}"
# If we can combine vac&mop, set them together and run. If not, do two separate cycles
- if:
- "{{combine}}"
then:
- service: vacuum.set_fan_speed
target:
entity_id: "{{vacuum_id}}"
data:
fan_speed: "{{fan if was_fan_custom else fan_initial}}"
- service: select.select_option
target:
entity_id: "{{mop_intensity_select}}"
data:
option: "{{mop_intensity if was_mop_custom else mop_intensity_initial}}"
- service: select.select_option
target:
entity_id: "{{mop_mode_select}}"
data:
option: "{{mop_mode if was_mop_mode_custom else mop_mode_initial}}"
- delay: "0:00:03"
- alias: "Vac&Mop the room"
service: roborock.vacuum_clean_segment
target:
entity_id: "{{vacuum_id}}"
data:
segments: "{{repeat.item}}"
repeats: "{{repeats}}"
- wait_for_trigger:
- platform: template
value_template: "{{is_state(vacuum_id,'cleaning')}}"
#need to add some error handling
- alias: "Wait until finished: status returning and battery > 20%"
wait_for_trigger:
- platform: template
value_template: >-
{{(is_state(vacuum_id,'returning') and state_attr(vacuum_id,'battery_level')|float(75) > 20)
or (is_state(vacuum_id,'docked') and state_attr(vacuum_id,'battery_level')|float(75) > 50)}}
- service: input_datetime.set_datetime
target:
entity_id: "input_datetime.vacuum_last_{{room}}"
data:
date: "{{now().date()}}"
else:
# Set up fan, mop off, just vac
- service: vacuum.set_fan_speed
target:
entity_id: "{{vacuum_id}}"
data:
fan_speed: "{{fan if was_fan_custom else fan_initial}}"
- service: select.select_option
target:
entity_id: "{{mop_intensity_select}}"
data:
option: "off"
- delay: "0:00:03"
- service: roborock.vacuum_clean_segment
target:
entity_id: "{{vacuum_id}}"
data:
segments: "{{repeat.item}}"
repeats: "{{repeats}}"
- wait_for_trigger:
- platform: template
value_template: "{{is_state(vacuum_id,'cleaning')}}"
- alias: "Wait until finished: status returning and battery > 20%"
wait_for_trigger:
- platform: template
value_template: >-
{{(is_state(vacuum_id,'returning') and state_attr(vacuum_id,'battery_level')|float(75) > 20)
or (is_state(vacuum_id,'docked') and state_attr(vacuum_id,'battery_level')|float(75) > 50)}}
- service: input_datetime.set_datetime
target:
entity_id: "input_datetime.vacuum_last_{{room}}"
data:
date: "{{now().date()}}"
# Fan off, set up mop, just mop
- service: vacuum.set_fan_speed
target:
entity_id: "{{vacuum_id}}"
data:
fan_speed: "off"
- service: select.select_option
target:
entity_id: "{{mop_intensity_select}}"
data:
option: "{{mop_intensity if was_mop_custom else mop_intensity_initial}}"
- service: select.select_option
target:
entity_id: "{{mop_mode_select}}"
data:
option: "{{mop_mode if was_mop_custom else mop_mode_initial}}"
- delay: "0:00:03"
- service: roborock.vacuum_clean_segment
target:
entity_id: "{{vacuum_id}}"
data:
segments: "{{repeat.item}}"
repeats: "{{repeats}}"
- wait_for_trigger:
- platform: template
value_template: "{{is_state(vacuum_id,'cleaning')}}"
- alias: "Wait until finished: status returning and battery > 20%"
wait_for_trigger:
- platform: template
value_template: >-
{{(is_state(vacuum_id,'returning') and state_attr(vacuum_id,'battery_level')|float(75) > 20)
or (is_state(vacuum_id,'docked') and state_attr(vacuum_id,'battery_level')|float(75) > 50)}}
# clean up
- service: vacuum.set_fan_speed
target:
entity_id: "{{vacuum_id}}"
data:
fan_speed: "{{fan_initial}}"
- service: select.select_option
target:
entity_id: "{{mop_intensity_select}}"
data:
option: "{{mop_intensity_initial}}"
- service: select.select_option
target:
entity_id: "{{mop_mode_select}}"
data:
option: "{{mop_mode_initial}}" |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I was wondering if anyone got an automation working that reliably first vacuums, then mops a selection of rooms, one by one? (vac room 1, mop room 1, vac room 2, mop room 2 etc.)
Time based seems like prone to errors and not that efficient. I'd rather have my Q to do the tasks one by one and be done instead of doing something, charging for x minutes, get back to work, then come back, empty / wash and go again.
Is there a way to tell the robot to first vac then mop before returning home? (Where I could check for "cleaning" and battery % before sending it out again?)
Anyone willing to share their script with us how to chain different cleaning commands to their Roborock?
Beta Was this translation helpful? Give feedback.
All reactions