Add simple automation turn on at specified time wait for period then off

Hi I am trying to add a simple automation to turn a light on then after a specified time to turn it off.
I can get one light in the house to turn on, but if i add another “add action” it seems to turn the light on a off again instantly and then nothing ends up happening at all.
how do i go about having a timer that move these two actions apart?

thanks

This just a basic delay action

alias: Example
description: ""
triggers:
  - trigger: state
    entity_id:
      - light.your_light
    to: "on"
conditions: []
actions:
  - delay:
      hours: 0
      minutes: 0
      seconds: 30
      milliseconds: 0
  - type: turn_off
    device_id: dd44eb2166f55448cba7f189cde7d150
    entity_id: 8c66a5558934c76560a3ad9e28f5efa0
    domain: light
mode: single

thanks for the super quick relay liquid cooled. I am trying to use settings: automations: to do this. Is this the correct place to use your delay action code/script thing? or am i as usual in completely the wrong area?

thanks again

The example I provided is an Automation

oh cool, so i am in the right area, I am assuming i can click settings: automations and scenes: then click create automation. select create new automation. then i can select from these three options add trigger, add condition, add action. does the code get added in one of these?

Yes I am showing you the YAML version

Use the GUI to start

the last time i played with the .config I f#cked my entire home assistant and was in the dark for a godamn week.

is there seriously no way to schedule a light to turn on and off without reprogramming the config of the home assistant?

I think you are slightly confused. You can create you automation entirely in the GUI

i just shared the option to see it in YAML via the 3 dots in the right corner menu

No need to edit config unless you feel comfortable with that method.

YAML code works well to communicate because this forum is global. Pictures do not always convey the message well.

A Guide

2 Likes

thanks liquid cooled, really appreciated!