Setting automation to run once a day

My roomba is set to run on an automation with conditions (when no one is home, between certain hours and on certain days).
But I want to add an additional constraint, that will limit it to run once every assigned day, not more (say my wife comes and goes during the day).
What would be the best direction to approach this?

1 Like

You could test the last.triggered attribute of the automation, or you could have the automation set an input_boolean when it runs.
You’d reference the input_boolean in same automation as a condition, state: off
Another automation would turn the input_boolean off at say midnight.

If you follow @jivesinger suggestion, ensure you have Recorder enabled so that the state of the input_boolean is preserved after Home Assistant restarts (see this thread for more info). The input_boolean serves as the “vacuuming done” flag so its state must survive a restart.

Another route worth exploring is to use the History Statistics Sensor to serve as the “vacuuming done” flag. It offers a small extra convenience: you don’t need an automation to reset it at midnight. In other words, there’s no need to reset the “vacuuming done” flag at the start of each new day because this approach uses date-math to calculate what represents “today”.

The documentation’s first example indicates how long a light’s been on for the current day. You can easily tweak it so it reports how long the roomba has been on today.

  - platform: history_stats
    name: Vacuuming Time Today
    entity_id: vacuum.my_roomba
    state: 'on'
    type: time
    start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
    end: '{{ now() }}'

To determine if the roomba should run today, your automation’s condition would check if sensor.vacuuming_time_today is zero. If it’s greater than zero then it has already run today.

Disclaimer: I don’t have a roomba so I have not tried my own suggestion! However, in theory, it should work. :slight_smile:

1 Like

Thanks! Im gonna give it a try over the next few days and see how the History Stats Sensor behaves. Surprised I havent seen it around before (tho still learning :slight_smile: )

small change and it works for me :slight_smile: Thanks!

state: 'cleaning'