Problem with Syntax for "wait" function in script

I’m trying to setup a script that if I trigger will turn off the lights when I play something on my media player. I’m not a coder so I’ve tried coping the syntax from the home assistant help. My problem is the script doesn’t wait it just moves on to the actions.

Thanks for your help!

'1595295885896':
  alias: Movie Lights
  sequence:
  - after: sunset
    condition: sun
  - condition: state
    entity_id: light.dimmable_light_4
    state: 'on'
  - condition: state
    entity_id: light.linear_nortek_security_control_llc_pd300z_2_plug_in_dimmer_module_level
    state: 'on'
    # Wait until media player have stop the playing
  - wait_template: "{{ is_state('media_player.living_room', 'playing') }}"
  - data: {}
    entity_id: light.linear_nortek_security_control_llc_pd300z_2_plug_in_dimmer_module_level
    service: light.turn_off
  - data: {}
    entity_id: light.dimmable_light_4
    service: light.turn_off
  - wait_template: "{{ not is_state('media_player.living_room', 'playing') }}"

Thanks! I’ll try that this evening.