Delay action in a automation

So i started from scratch a couple of weeks ago and i’m trying to set up my automations.

I made one which will turn of the light but i want to build in a delay for a couple of minutes. What do i need to add to my automation?

 - id: '1580225592546'
  alias: 05. Turn off the lights when i turn off the tv
  description: ''
  - entity_id: media_player.livingroom_tv
    from: 'on'
    platform: state
    to: 'off'
  - after: '22:00'
    condition: time
  - alias: ''
    data: {}
    entity_id: group.night_lights
    service: homeassistant.turn_off
1 Like

So i need to make a script? And add the script as an action to my automation?
I feel a headache coming up :smiley:

No, I think tediore is pointing at the delay (not sure though) replace the above with : -

  - delay: '00:02:00'
  - service: homeassistant.turn_off
    entity_id: group.night_lights

Action formats (in automations) are pretty much exactly the same as sequences in scripts.
A script allows you to reuse the same code in many places and you can free up the automation for the next trigger.
Though you should be aware that if you trigger this again, with the delay still running, it will bypass the delay and run straight to the action.
You can do things to prevent this but it always involves an overhead

As Mutt said, clicking the link shows you how to add a delay to a script/automation. The action block of the automation is essentially a script, so the actions you see on the scripts page can be used in the action block of an automation.

Yeah i figured i was having a blond moment when i was cooking (good time for thinking) later on.

I’ve updated the script and will run a test shortley

Well thats interesting. Yes it works. But it seems that it takes a while for HA to notice i turned of the tv. So i guess, no delay needed… I’m going to monitor for a while.