How do you turn off a light 5 minutes after it was turned on

Automations have changed. It used to be so easy to do this. But I have been fingering with it for a while now with zero progress.

I can easily get the light to turn on after motion is detected, but I cannot figure out a way to add a delay to turn it off.

Thanks for any help,
Gramps

There are many ways… it all depends on what you are trying to do.

One basic option is to use an automation with a State trigger that has a defined duration:

trigger: state
entity_id: light.example
to: "on"
for: "00:05:00"

If you want to do it in the same automation in which you turned the light on, you can use a Delay action then turn off the lights:

...
actions:
  - action: light.turn_on
    target:
      entity_id: light.example
  - delay: 
      minutes: 5
  - action: light.turn_off
    target:
      entity_id: light.example

Another option would be using a timer instead of a Delay action.

thanks, some progress !!

curious why can I not find delay in the visual editor? That is what I have been looking for
image

alias: Motion fireplace Budro Turn on
description: ""
triggers:
  - type: motion
    device_id: 65d6141a67b2c17e50ad77b98d0a2886
    entity_id: 911b0baa96d20106e436beab545720b0
    domain: binary_sensor
    trigger: device
conditions: []
actions:
  - action: light.turn_on
    metadata: {}
    data:
      brightness_pct: 100
      kelvin: 6500
    target:
      entity_id: light.big_room_bulb_3
  - delay:
      minutes: 1
  - action: light.turn_off
    metadata: {}
    data: {}
    target:
      entity_id: light.big_room_bulb_3
mode: single

I think it is working. Again where is delay in the visual editor. That is what I used to use?

Thank you, thank you,
Gramps

EDIT, just set to 15 seconds for testing

It’s under “Building Blocks” with all the various Wait actions, but it will also show up if you search “wait” or “delay”.

image

1 Like