Running Automation once each morning


New to Home Assistant (migrating from SmartThings) and I’m just setting up my devices.

I’m having trouble setting up a motion sensor to disarm an alarm in the morning. At the moment, I have a condition to run the automation after motion is detected after 6am. But this will disarm the alarm each time motion is detected, I only want it to run once.

I’ve tried adding an action at the end of the automation “wait for time to pass = 21 hours” but doesn’t seem to have made a difference.

Any suggestions? In SmartThings there’s an option to run an automation once perday - looking to recreate that with Home Assistant.

Add a condition to the automation that the alarm is armed.

I can think of three ways to solve this:

  • Create an input_boolean (e.g., input_boolean.morning_alarm_deactivated)
  • Create a condition so the automation only runs when the input_boolean is off
  • Set the input_boolean to true as an action of the automation
  • Create another automation to run at midnight which will set the input_boolean back to off.


  • Set the automation to trigger at 6am
  • Create a wait / wait_for_trigger action with a timeout of your choice (e.g., 6 hours), see docs, have the wait template configured to wait until your motion sensor turns on
    • Set continue_on_timeout: false


  • Have the automation trigger when there’s motion
  • Have a condition that checks if it’s after 6AM
  • Create a template condition to check for the last_triggered attribute of your automation, if it hasn’t run today (yet), continue

That would always disarm the alarm once motion is detected.
For example, if motion is detected at 6 AM, the alarm will be disabled, then the alarm may get armed later, but when motion is detected later (e.g., at 2 PM), the alarm will again be disarmed.

Interested in pursuing this option, but not sure what to enter in the “value template” box? …

This might do the trick (change the NAME to match your automation, you can see it in the URL bar while editing):

{{ state_attr('automation.NAME', 'last_triggered').strftime('%Y-%m-%d') != now().strftime('%Y-%m-%d') }}

However, please test it, since as soon as the automation triggers, the last_triggered attribute may be set to now.

I’m going to give this method a try …

This will always disable the alarm when there’s movement in the house from 6:00-23:59, just saying

I thought it would only disable the alarm if it was after 6am and the alarm was in an “armed state” for longer than 1 hour?

Yes, I’m just not sure you’d want to disable the alarm when there’s motion in your house :smiley: But if it works for this specific scenario…

Add as a condition. The time window in template 10800 (seconds) determines how long it checks whether automation has already started.

condition: and
  - condition: time
    after: '07:00:00'
    before: '10:00'
  - condition: template
    value_template: >-
      {{ (as_timestamp(now()) -
      as_timestamp(states.automation.rano.attributes.last_triggered |
      default(0)) | int > 10800)}}

Change the time and name of the automation as needed

1 Like