Delay not working anymore

Hi
I have a problem with all my automations which have a Delay not working anymore, they all used to work ! I am running 95_4

Here is one automation which used to work but now doesnt…
I have tried putting quotes around the delay time but still didnt help

- id: '1560152741944'
  alias: Sprinkler Timer
  trigger:
  - entity_id: switch.sprinklers
    platform: state
    to: 'on'
  condition: []
  action:
  - alias: Send an Email
    service: notify.email_fred
    data:
      message: Sprinklers Turned ON
  - delay: 00:02:00
  - service: homeassistant.turn_off
    entity_id: switch.sprinklers
  - alias: Send an email
    service: notify.email_fred
    data:
      message: Sprinklers Turned OFF

What exactly do you mean by “doesn’t work”?

Are you seeing any errors in your log? What does the log (i.e., home-assistant.log) show for the steps of the automation?

sorry, I thought this should read ‘00:02:00’ ???

It should, and you can tell that it’s a problem with the syntax highlighting.

@dudester, start by adding quotes around the time value and go from there.

One quirk with delays is that if the automation triggers and hits a delay and then the automation triggers again, execution will immediately fall through the delay (but doesn’t re-execute any of the earlier steps). There’s a thread about it here, and it’s possible that it could be affecting you.

Always worked perfectly without quotes, must have happened after an upgrade, adding quotes makes no difference, no delay

You need to explain more about what “doesn’t work” means. That is way too vague.

Although, one thing to check (since I don’t see anything obviously wrong with your automation) is if the automation is turned on. It was a common problem that automations could easily be turned off under certain conditions.

And if you indent the code like this?

- id: '1560152741944'
  alias: Sprinkler Timer
  trigger:
    - entity_id: switch.sprinklers
      platform: state
      to: 'on'
  condition: []
  action:
    - alias: Send an Email
      service: notify.email_fred
      data:
        message: Sprinklers Turned ON
    - delay: '00:02:00'
    - service: homeassistant.turn_off
      entity_id: switch.sprinklers
    - alias: Send an email
      service: notify.email_fred
      data:
        message: Sprinklers Turned OFF

There’s nothing wrong with the indentation in the OP. It’s perfectly legal YAML.

Yes automations are ON.
The automation works except the delay is ignored, always worked perfectly with delay occurring before upgrade. I have other routines with delays in the same format which all now no longer delaying at all.

I did see something about an alternative using script but I didnt understand how to do that.

If switch.sprinklers changes to on, then changes to off and back to on again before the two minute delay is complete, then yes, the result would be that the delay would be aborted and the automation would continue with the next step. (I.e., it does not restart the actions from the beginning.)

Do you think that might be happening?

You should look in home-assistant.log. E.g., when one of my automations runs which contains a delay I see these in the log:

2019-09-07 14:46:48 INFO (MainThread) [homeassistant.helpers.script] Script Foyer Snapshot: Running script
2019-09-07 14:46:48 INFO (MainThread) [homeassistant.helpers.script] Script Foyer Snapshot: Executing step call service
2019-09-07 14:46:48 INFO (MainThread) [homeassistant.helpers.script] Script Foyer Snapshot: Executing step delay 0:00:01
2019-09-07 14:46:50 INFO (MainThread) [homeassistant.helpers.script] Script Foyer Snapshot: Executing step call service

Note that the action part of an automation is actually a script and is therefore executed by the homeassistant.helpers.script module.

I dont see that…
I am looking in the in the Log under Developer Tools, is there a better way to view to log?

No, that’s the System Log.

You need to look at the home-assistant.log file in your config directory. You may need to set the logger:

logger:
  default: info