A robot vacuum is great until it decides to clean the living room right when you sit down with a coffee. I wanted mine to follow a few simple house rules:
- Clean once a day.
- Only when nobody is home.
- Only during the day, between 10:00 and 18:00.
- If someone comes back mid-run, pause. If they leave again quickly, resume. If they stay, go back to the dock and try again at the next opportunity.
Here is how I built it in Home Assistant with one helper and four automations.
What you need
- Home Assistant with your robot vacuum integrated. In the examples it is
vacuum.robot_vacuum: replace it with your own entity ID. Anyvacuumentity works, whatever the brand. - Presence detection for everyone in the house. I use the Home Assistant Companion app on each phone.
- Each phone's
device_trackerassigned to a Person (Settings → People → Track devices).
That last point matters. It powers the entity this whole setup depends on: zone.home.
Why zone.home instead of a group
My first version used an old-school group of phone trackers:
phone_group:
name: PhoneGroup
entities:
- device_tracker.phone_1
- device_tracker.phone_2
- device_tracker.phone_3
A group of trackers is home when at least one member is home and not_home otherwise. It works, but there is a cleaner built-in option.
zone.home's state is the number of people currently at home. No group to maintain: add a person, and they are counted automatically. "Nobody is home" becomes zone.home < 1, and "someone is home" becomes zone.home > 0.
Since the state is a number, the right tool is a numeric_state trigger or condition, not a state one. More on that in the gotchas section.
Step 1: a "cleaned today" flag
I need to remember whether the vacuum already cleaned today. That's a job for an input_boolean. You can create it in the UI (Settings → Devices & services → Helpers → Create helper → Toggle) or in configuration.yaml:
input_boolean:
vacuum_cleaned_today:
name: "Vacuum cleaned today"
icon: mdi:robot-vacuum
Watch out: no
-under the helper ID. I first wrote- name: ..., which turns the properties into a list. Home Assistant rejected the whole helper with "expected a mapping for dictionary value", and my automations then complained about an unknown entity. The-is for lists of things (triggers, actions, group members), not for describing a single object.
Step 2: the four automations
All four go into automations.yaml as-is, or into the UI editor one at a time via ⋮ → Edit in YAML (drop the leading - ). They use the current syntax: triggers / conditions / actions, trigger: instead of platform:, and action: instead of service:.
1. Start when nobody is home
- id: vacuum_start_when_away
alias: "Vacuum - Start when nobody is home"
mode: single
triggers:
# 5 minutes after the last person leaves
- trigger: numeric_state
entity_id: zone.home
below: 1
for: "00:05:00"
# everyone already left before 10:00
- trigger: time
at: "10:00:00"
conditions:
- condition: time
after: "10:00:00"
before: "18:00:00"
- condition: numeric_state
entity_id: zone.home
below: 1
- condition: state
entity_id: input_boolean.vacuum_cleaned_today
state: "off"
- condition: state
entity_id: vacuum.robot_vacuum
# some models report "idle" on the dock, see the gotchas below
state: "docked"
actions:
- action: vacuum.start
target:
entity_id: vacuum.robot_vacuum
There are two triggers because there are two ways to end up "home empty, during the cleaning window":
- Everyone leaves during the window. The first trigger fires after 5 minutes of an empty house. The delay keeps a phone that briefly drops off Wi-Fi from launching a run.
- Everyone left before 10:00. Nothing changes at 10:00, so the second trigger re-checks at the start of the window.
The conditions then make sure that the time is right, the house is still empty, the vacuum hasn't run today and it is sitting on its dock.
2. Mark today as done
- id: vacuum_mark_cleaned_today
alias: "Vacuum - Mark today's cleaning"
mode: single
triggers:
# any start, automatic or manual
- trigger: state
entity_id: vacuum.robot_vacuum
to: "cleaning"
actions:
- action: input_boolean.turn_on
target:
entity_id: input_boolean.vacuum_cleaned_today
I deliberately trigger on the vacuum's state rather than setting the flag in automation #1. This way a run started from the manufacturer's app or the button on the robot also counts.
3. Pause when someone comes home
This is the most interesting one.
- id: vacuum_pause_on_return
alias: "Vacuum - Pause when someone comes home"
mode: single
triggers:
- trigger: numeric_state
entity_id: zone.home
above: 0
conditions:
- condition: state
entity_id: vacuum.robot_vacuum
state: "cleaning"
actions:
- action: vacuum.pause
target:
entity_id: vacuum.robot_vacuum
- wait_for_trigger:
- trigger: numeric_state
entity_id: zone.home
below: 1
timeout: "00:10:00"
- choose:
# still someone home after 10 minutes: back to the dock
- conditions: "{{ wait.trigger is none }}"
sequence:
- action: vacuum.return_to_base
target:
entity_id: vacuum.robot_vacuum
# not finished: it will try again at the next absence (10:00-18:00)
- action: input_boolean.turn_off
target:
entity_id: input_boolean.vacuum_cleaned_today
# nobody home again: resume
default:
- action: vacuum.start
target:
entity_id: vacuum.robot_vacuum
When the first person arrives, the vacuum pauses immediately, then the automation waits up to 10 minutes:
- The house empties again (someone just popped in to grab their keys):
wait.triggeris set, so we fall through todefaultand resume cleaning. - The timeout expires (
wait.trigger is none): someone is staying. The vacuum goes back to its dock and I reset the "cleaned today" flag. That run doesn't count, so automation #1 can start a fresh one at the next absence within the window.
4. Reset at midnight
- id: vacuum_reset_at_midnight
alias: "Vacuum - Reset at midnight"
mode: single
triggers:
- trigger: time
at: "00:00:00"
actions:
- action: input_boolean.turn_off
target:
entity_id: input_boolean.vacuum_cleaned_today
New day, new chance to clean.
How it plays out
| Situation | What the vacuum does |
|---|---|
| Last person leaves at 11:30 | Starts at 11:35 |
| Everyone left at 8:00 | Starts at 10:00 |
| Last person leaves at 19:00 | Nothing, outside the window |
| Someone comes back for 3 minutes mid-run | Pauses, then resumes |
| Someone comes back for good mid-run | Pauses, docks after 10 min, retries at the next absence |
| Already cleaned today, house empties again | Nothing |
| Started by hand from the app | Counts as today's run |
Gotchas I ran into
The UI won't offer 0 or 1 for zone.home. With a State trigger, the "From/To" dropdown only lists Unavailable and Unknown, because the state is a number and the UI can't list numbers in advance. Use a Numeric state trigger with Above / Below instead.
numeric_state is more robust than to: "0". A state trigger with to: "0" can also fire when Home Assistant starts and zone.home goes from unknown to 0, which looks like "everyone just left" when nobody did. A numeric_state trigger only fires when the value actually crosses the threshold. Note that "nobody home" is below: 1, not below: 0: the count can never go negative, so below: 0 never fires.
docked vs idle: check your robot's states. The state names depend on the integration and the model. A vacuum sitting on its dock may report idle instead of docked, and some never report docked at all. If yours does that, automation #1 will never start it. Check Developer tools → States while the robot is charging, and again while it is cleaning (cleaning is used in automations #2 and #3), then adapt the conditions to what your robot actually reports.
Give automations an id. Without it, automations written in automations.yaml can't be edited in the visual editor.
Validate before reloading. Developer tools → YAML → Check configuration catches indentation and structure errors and points to the exact file and line. Once it's green, reload Automations (and Input booleans) from the same page. No full restart needed.
Ideas for later
- A notification when the run finishes, or when the vacuum gets stuck.
- Skip days, for example a
workdaycondition or a "guests" toggle. - Room-specific cleaning (kitchen every day, bedrooms twice a week), if the integration supports segments.
For now, my vacuum has learned the most important rule of shared living: do your chores when nobody's watching, and get out of the way when someone walks in.