Action Delay doesn't works if the delay is more than 10 hours

Hello,

I’m doing a simple automation, the trigger is turn light on on sunset and the action is delay for 12 hours for turn light off. I noticed that if the delay is more than 9 to 10 hours, the delay will not execute. Any ideas??

Here is my automations:

  • id: ‘1616260056490’
    alias: Altar Light
    description: ‘’
    trigger:
    • platform: sun
      event: sunset
      offset: -01:00:00
      condition: []
      action:
    • type: turn_on
      device_id: 8af326f3c58049e78bc7a2f62ffe331b
      entity_id: switch.altar_light
      domain: switch
    • delay:
      hours: 10
      minutes: 0
      seconds: 0
      milliseconds: 0
    • type: turn_off
      device_id: 8af326f3c58049e78bc7a2f62ffe331b
      entity_id: switch.altar_light
      domain: switch
      mode: single

Thank you

Please format your pasted config correctly.

Have you considered using a seperate automation to turn the lights off?

Either some offset before sunrise trigger, or a sunset trigger with a +10 offset?

You should report this as an issue on github (HA core repository).

Hi,
Sorry, my first time posting a question. What do you mean “format your pasted config correctly”? I started with separate automation to turn off light but it is logical to combine the on and off into one automation. I have the combined automation that works for on and off but less than an hour delay only.
Thanks

Please see point 11 here: How to help us help you - or How to ask a good question

1 Like

If Home Assistant is restarted during the execution of a delay, on startup the delay is not resumed (i.e. the remainder of the delay is not completed and whatever action that may appear after the delay is not executed).

Are you certain it was never restarted during the 9+ hour delay?

Got it! Thanks for the info!

Yes, I’m sure that HA never restarted.

I just created an automation containing a 10-hour delay. I triggered it and its currently counting down its delay. After 10 hours it will create a persistent notification. I’ll report my results tomorrow (the server is connected to a UPS so there’s little chance of interruption).

Here’s the simply automation I used to test the 10-hour delay:

Click to reveal
alias: delay test
description: ''
trigger:
  - platform: state
    entity_id: input_boolean.test
    to: 'on'
condition: []
action:
  - delay:
      hours: 10
      minutes: 0
      seconds: 0
      milliseconds: 0
  - service: notify.persistent_notification
    data:
      title: Delay Test
      message: '{{ now().timestamp() | timestamp_local() }}'
mode: single

Here’s the trace proving it waited 10 hours before issuing the notification.

Screenshot from 2021-04-09 08-27-46

The resulting notification:
Screenshot from 2021-04-09 08-32-07

Feel free to repeat the same experiment on your system.

Not only restarting HA, also reloading automations will cancel all ongoing automations. And besides a manual reload of the automations, a reload is also performed when you edit/create/delete an automation from the UI.

1 Like

Exactly. Just one of the many reasons I don’t employ lengthy delays in my automations.

1 Like