Problems with a script and Alarmo

I have some problems with my Alarmo setup. I’ve setup the Alarmo part with sensors etc and now I want to setup a script for running the Siren on my Sonos speaker.
This script causes 2 problems:

First problem: The sound is not coming clear and in the right tempo. It sounds like there is problems transferring the sound etc - even the sound is uploaded to HA. It just like some dots in the speaker. When the alarm is disarmed, the right sound starts to run and finish when the sound file ends.

Second problem:
This script should do that the sound will be repeat over and over again until alarm is disarmed but it doesn’t happen - or maybe but the sound which comes out is not the right.

Can anybody look at this script and see if there is any errors etc? Or what could cause these problems?

alias: Sirene
sequence:
  - service: media_player.volume_set
    data:
      volume_level: 1
    target:
      entity_id: media_player.dining_room
  - repeat:
      until:
        - condition: state
          entity_id: alarm_control_panel.alarmo
          state: disarmed
      sequence:
        - service: media_player.play_media
          target:
            entity_id: media_player.dining_room
          data:
            media_content_id: media-source://media_source/local/TF006.WAV
            media_content_type: audio/x-wav
          metadata:
            title: TF006.WAV
            thumbnail: null
            media_class: music
            children_media_class: null
            navigateIds:
              - {}
              - media_content_type: app
                media_content_id: media-source://media_source
  - wait_template: "{{ is_state(\"media_player.dining_room\", \"idle\") }}"
    continue_on_timeout: true
mode: single

You may need a delay in your repeat loop to avoid calling each subsequent play_media service on top of the last one.

Any idea how to add this? And will this solve both problems, you think?

You add a delay action after the play_media service call… I set the value to 5, but you should change the delay so that it is at least the same as the length of your audio file.

alias: Sirene
sequence:
  - service: media_player.volume_set
    data:
      volume_level: 1
    target:
      entity_id: media_player.dining_room
  - repeat:
      until:
        - condition: state
          entity_id: alarm_control_panel.alarmo
          state: disarmed
      sequence:
        - service: media_player.play_media
          target:
            entity_id: media_player.dining_room
          data:
            media_content_id: media-source://media_source/local/TF006.WAV
            media_content_type: audio/x-wav
          metadata:
            title: TF006.WAV
            thumbnail: null
            media_class: music
            children_media_class: null
            navigateIds:
              - {}
              - media_content_type: app
                media_content_id: media-source://media_source
        - delay: 5
mode: single

Maybe. Does the sound play correctly if you only send it once?

Perfect, thanks a lot! That solved my problems