Hi everyone! I am trying to automate my vacuum cleaner to:
Clean when I am not at home
Clean everyday (if I am away)
Not clean more than once a day (within 24hrs)
From my automation below, the automation is activated when ‘away mode’ is activated and if the vacuum has not been on for the last 24hrs.
I am stuck on the ‘clean everyday’ part… anyone got any best practices on how I can handle that bit? I want it to clean everyday I am away. I don’t think setting a specific time to clean would work given that I leave the house at different times each day.
- id: '1604430133826'
alias: 'Robovac: Clean when I am not home'
description: When I am not home, run the vacuum cleaner if it has not ran for the
past 24 hours
trigger:
- platform: state
entity_id: input_boolean.away_mode
from: 'off'
to: 'on'
condition:
- condition: state
entity_id: input_boolean.away_mode
state: 'on'
- condition: state
entity_id: vacuum.robovac
state: 'off'
for:
hours: 24
action:
- data: {}
entity_id: vacuum.robovac
service: vacuum.start
So I have it run at a certain time each day if home group (wife and I) is away. This leads to it not running every day but generally it runs 4-5 days a week and truthfully that is plenty to keep it clean. Doing it this way was much simpler since it doesn’t require turning on and off a boolean. But here’s how to do it not with time as a trigger:
If its just you use your .person entity or if more than you make a group with the other person entities as the trigger. Use that as the trigger when it goes to not_home and trigger the following actions:
a. run the vacuum
b. turn on “vacuum_ran_today” input boolean
condition the above on “vacuum_ran_today” boolean being off.
this ensure that if you leave home more than once in a day it wont run twice
make another automation to run once a day to turn off the “vacuum_ran_today” bolean
I have a few booleans that get reset daily so I run the reset at midnight.
Just do a single automation with a wait_template. A wait_template is a sequence that waits (forever or until a timeout) for something to evaluate to true.
It will run the same time every day, then wait for you to be away.
- alias: Vacuum
mode: single
trigger:
- platform: time
at: "09:00:00"
action:
# Starts at 9 am, and waits until this turns on.
# If this is already on, no waiting will happen.
- wait_template: "{{ is_state('input_boolean.away_mode', 'on') }}"
# Optional - add a timeout for how long this will wait.
timeout: "06:00:00"
continue_on_timeout: false
- service: vacuum.start
entity_id: vacuum.robovac
Downside is it wont be a strict 24 hour cycle. It might run at 11 am one day, then 9 am the next day. I’m guessing your main concern with the 24 hour timeout is so it didn’t run every time you were away.