[SOLVED] What is the trigger for script started?

Hi everybody,

I have an automation that will run an “alarm clock” at a certain (variable!) time in the morning. The alarm clock is a sonos beam playing music and an ESPHome turning on and slowly brightening an LED strip.

Due to me usually waking up before the alarm, I sometimes forget to turn it off manually. When I don’t turn it off, it will eventually trigger, and then the LED will be on until somebody manually turns it off.

So I am hoping to automate this, kinda like this

automation:
  - id: "bla"
    trigger:
      platform: # what goes here?
    - delay:
      minutes: 30
    action:
      - service: light.turn_off
        entity_id: light.schlafzimmer_bett

This should be triggered as soon as script.wecksong and/or script.wecklicht are started; both scripts are started at the very same time, so I could just watch for either of them to be triggered. Then iit should wait 30 minutes, and then turn off the LED. The music will automatically turn off after a couple of minutes (depending on the song / audio file), so there is no need to turn that off via automation.

I just don’t know what platform to use so that it will trigger when I start the script.

Thank you for your help :slight_smile:

automation:
  - id: "bla"
    trigger:
      - platform: state
        entity_id: script.wecksong 
        to: 'on'
      - platform: state
        entity_id: script.wecklicht
        to: 'on'
    action:
      - delay:
        minutes: 30
      - service: light.turn_off
        entity_id: light.schlafzimmer_bett

Note that if your automation triggers more than once it will skip the delay the second time and proceed to the next action.

Thank you so much @tom_l :pray:

UPDATE / EDIT: actually, I had to change your solution a little bit in order for it to work.

# (...)
      action: 
      - delay: 00:30:00 
      - service: light.turn_off
        entity_id: light.schlafzimmer_bett 

When I specified minutes for the delay, I’d constantly get an error when re-starting Home Assistant.