I’ve just written an automation so that when the house is empty, the vacuum with clean a predefined set of rooms. So in the example below it will clean the toilet, porch and kitchen for me. Before cleaning each room it will check it has 20% battery left and after cleaning the room it will update a date time helper for me so that I know what the room was last automatically cleaned
I’m struggling however to add in conditions that it only cleans a specific room if it’s not been cleaned within the last x hours.
There is an automation that will return the vacuum to dock of we come back home. So if it has cleaned the toilet and porch, then we return home. If we leave again for period later on, the automation should check the last time the toilet and porch were cleaned and ignore these, since they are already clean, but it should start from the kitchen and clean this for us.
alias: Empty Home - Activate Vacuum
description: ""
trigger:
- platform: state
entity_id: binary_sensor.home_status
from: "on"
to: "off"
for: "00:01:00"
action:
- variables:
rooms:
- toilet
- porch
- kitchen
- repeat:
while:
- condition: template
value_template: >-
{{ repeat.index <= rooms|count and
state_attr('vacuum.roborock_s5_max','battery_level')|int(0) > 20 }}
sequence:
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.roborock_last_clean_{{ rooms[repeat.index - 1] }}
data:
timestamp: "{{ now().timestamp() }}"
- service: script.roborock_clean_room
data:
room: "{{ rooms[repeat.index - 1] }}"
- wait_template: "{{ is_state('vacuum.roborock_s5_max', 'returning') }}"
mode: single
Any help much appreciated on this issue
Thank you