Automation with definitive action followed by conditional action?

I have an automation that plays an audio file of a barking dog when Frigate detects someone on my back deck. I’d like to extend this automation so that it also turns on the bedroom light three seconds after the audio file plays. The automation needs to be written so that it can play over and over in case the person stays on the back deck, but the light only turns on once.

Here is the code that I want to revise:

description: ""
mode: single
trigger:
  - platform: mqtt
    topic: frigate/events
condition:
  - condition: and
    conditions:
      - condition: template
        value_template: "{{ trigger.payload_json['after']['label'] == 'person' }}"
      - condition: template
        value_template: "{{ 'rear_deck' in trigger.payload_json['after']['entered_zones'] }}"
      - condition: template
        value_template: "{{ 'rear_deck' in trigger.payload_json['after']['current_zones'] }}"
      - condition: state
        entity_id: input_boolean.switch_arm_security_system
        state: "on"
      - condition: state
        entity_id: input_boolean.switch_sonos_plays_dog_barking
        state: "on"
action:
  - service: media_player.volume_set
    data:
      volume_level: 1
    target:
      entity_id: media_player.master_bedroom
  - service: media_player.play_media
    data:
      media_content_type: music
      media_content_id: /media/local/guard_dog_barking.mp3
      enqueue: false
    target:
      entity_id: media_player.master_bedroom
  - delay:
      hours: 0
      minutes: 1
      seconds: 8
      milliseconds: 0
  - service: media_player.clear_playlist
    entity_id: media_player.master_bedroom
max_exceeded: silent

Any advice would be greatly appreciated.

I should add that I think I need to add a “choose” before the 1:08 delay, where the choose turns on the bedroom light if it is off. But I am not sure if HA will continue running the rest of the code if it is already on.

It should work as you expect it to the way it is right now.

If the light is already on then the automation just continues as usual.

Have you tested it and are sure it doesn’t work?

@finity The problem is I don’t know exactly how to revise the code to include the “choose” action.

why do you think you need to use the choose: in the first place?