Turn light on for 30 seconds?

Hey all!

Is there a way of getting a light to turn on for only a few seconds without using a second automation?

All the examples I’ve seen have things where 1 automation turns the light on, and another turns it off x minutes after the first automation’s trigger.

I’d like to limit this to just one automation if possible?

Yes, use a delay:

  - service: light.turn_on
    entity_id: light.YOURLIGHT
  - delay: 00:00:30
  - service: light.turn_off
    entity_id: light.YOURLIGHT

You can use those in scripts, or in the action component of an automation.

Yep, works - thanks!

For others that had the same issue as I did, here’s my working YAML config under automation:

#Automations
automation:
  - alias: "1: Hall light on for 30 secs if TV turned off after dark"
#    name: tv_hallway_light_on
    trigger:
      - platform: state
        entity_id: media_player.sony_bravia_tv
        to: 'off'
    condition:
      - condition: state
        entity_id: sun.sun
        state: "below_horizon"
    action:
      - service: light.turn_on
        entity_id: light.main_light
      - delay: 00:00:30
      - service: light.turn_off
        entity_id: light.main_light