Disable Automation from Triggering (aka Bypass) for N hours?

Hoping someone has a complete example they can share with an HA new guy…

I have several situations where I want automations not to trigger for N hours.

Examples: working on the garage (dont want motion or door notifications), super windy day (disable back yard motion notifications), etc

Ideally I could setup a single Helper, per automation, with the selection of delay times: 1 hr, 2 hrs, etc
… after such time the automation resumes as normal.

In the initial sent notification, it would have an option to disable ‘for a period of time’ with a selection drop-down to select the amount of delay

thanks for the help!

There are multiple ways, though you should also consider if they work when HA restarts. Personally I use timers. They can restore on HA restart, you can cacel them, prolong them, see if they are running and test for them in other automations too. They give the most amount of control.

If it’s not that important that it works all the time then a delay at the end of the automation will prevent it from running again while the delay is running.

A restart or reload of that automation will break this though

Would be nice to have them persist across reboots but not required if its a lot more setup/config.

The bypass is to literally stop the notifications from happening - thus stop the automation (aka 'Do-Not-Retrigger) for a selectable timeframe like the below Helper screenshot… can a ‘delay’ do that?

would love to see examples you both use?

Delays only work for do not do again. Just put a delay action at the end.

But for some examples they won’t work, because you can only start the pause from the action and not for instance say: when a wind gust above x is detected, no not lower the awning for x time.

Tmier persistence is just a checkmark on you set when creating them in the Helper GUI. Starting, stopping etc is well documented:

Testing if a timer is running to stop an action is as simple as:

conditions:
  - condition: not
    conditions:
      - condition: state
        entity_id: timer.control_override
        state: active

seems like this is going to be complicated?

the flow need to be this…

  1. Automation triggers if Timers is not running
  2. Notification is sent
  3. Notification presents user with option to Pause Notifications with a way to select a timeframe (1 hr, 2hr, etc)
  4. User selects timeframe
  5. Timer is set based on User selection

result :: automation cannot retrigger until Timer runs out

I only know how to do 1 & 2, not the others

Here is an example:

Start a timer with a configurabe duration (in minutes, change multiplication for anything else):

      - action: timer.start
        data: 
          duration: "{{ states('input_number.myduration') | int(0) * 60 }}"
        target:
          entity_id: timer.test

Timers are not adhoc / dynamic? Meaning I must manually create (and uniquely name) a Timer for each separate automation?

This is definitely more complex and less UI based than I was expecting.

Also seem like this workflow is not documented anywhere?

I think this is the workflow…

  1. Create Timer specific to a given Automation
  2. Create Actionable Notification… allow user to select number which is passed to Timer to set the upper limit of the time.
  3. Create Automation
    – add Timer as a Condition… do not trigger while Timer = 0
    – add Actionable Notification as Action

I’ve spent 2 hours on this and still cant figure out how to send an Actionable Notification with a number list for the user to select from, and how to pass that to the Timer

Keep in mind that - at least for Android, not sure for iDevices - you can only send a max of 3 selectable actions in your Actionable Notification, e.g.

Or in your case somthing like:

  • 1h
  • 2h
  • 4h

Looks like we cant get direct user input (number from on-screen keyboard) or provide a drop-down list?

What does the code look like that takes those responses and places them into the timer?

thx for the help… HA is all new to me and several things are more difficult to do (like this) than my prior home automation system.

Correct - that’s not how actionable notifications work.

I don’t have a timer set up that way, but here’s an actionable notification triggered by an alert that the lights in my garage have been on for more than 5min:

alert:
  garageswitch_on_for_long:
    name: Garage Lights are still on!
    entity_id: switch.garageswitch_switch_1
    repeat: 5
    can_acknowledge: true  # Optional, default is true
    skip_first: true  # Optional, false is the default
    data:
      tag: garage_light_is_on
      priority: high
      actions:
        - action: garageswitch_switch_1_off
          title: Turn Light Off
      channel: Alert
      importance: high

And here is the code that uses the response to turn off the garage lights:

alias: Alert Action - Switch Garage Light Off
description: ""
mode: single
triggers:
  - event_type: mobile_app_notification_action
    event_data:
      action: garageswitch_switch_1_off
    trigger: event
conditions: []
actions:
  - data: {}
    target:
      entity_id: switch.garageswitch_switch_1
    action: switch.turn_off

That is incorrect… as I answered on the other thread you posted to.

Instead of messing with all the timers I would probably just use a Number Helper and template condition… if you use the slugified entity ID of the automation as the object ID of the number you could use the following condition in each automation:

condition:
  - condition: template
    value_template: >
      {% set n_hours = states('number.'~this.entity_id | slugify) | int(0) %}
      {{ now() > this.attributes.last_triggered | default(as_datetime(0),1)
      + timedelta(hours = n_hours ) }}

I stand correct! :person_standing:

Thanks for this :+1:

I didnt see that - nice!