Media player sonos limited local file playback time?

Hi everybody,

when I try to play a local file via media_player on a Sonos Beam, it will start playback fine, but not play the file until the end. Is there something I need to add to this configuration?

script:
# {{{ Audio 
  wecksong:
    sequence:
      # light 1 dark red to medium warm orange
      - service: media_player.volume_set
        data:
          entity_id: media_player.schlafzimmer
          volume_level: 0.1
      - service: media_player.play_media
        data:
          entity_id: media_player.schlafzimmer
          media_content_type: 'audio/mp4'
          media_content_id: 'http://ip:8123/local/audio/morgen.mp3'
          # media_content_id: 'http://ip:8123/local/audio/birds.mp3'
          # media_content_id: 'http://ip:8123/local/audio/spooky_scary_skeletons.mp3'
      - delay:
         seconds: 15
      - service: media_player.volume_up
        entity_id: media_player.schlafzimmer
      - delay:
         seconds: 15
      - service: media_player.volume_up
        entity_id: media_player.schlafzimmer
      - delay:
         seconds: 15
      - service: media_player.volume_up
        entity_id: media_player.schlafzimmer
      - delay:
         seconds: 15
      - service: media_player.volume_up
        entity_id: media_player.schlafzimmer
#}}}

This is part of my morning alarm. It is supposed to start a song at minimum volume, turning volume up every x seconds (15), and just be done when audio playback has finished (implementing snooze/off button is for later).

I have tried this with three different mp3 files so far. Each one can be found on YouTube:

(the reason I link these is so that you can see these files aren’t broken, nor ridiculously long so that my Sonos might not be able to play them)

Since the sonos will start playback, the files are both accessible to it, and the script syntax must be correct (id, type, …). However, the will stop playing after a while. Do I need to add anything after the last media_player.volume_up to assure that the file will continue to play? Is this a sonos issue? Or do you have another idea what might cause this?

Thanks for your ideas :slight_smile:

Anybody?

I changed each

- delay:
  seconds: 15

to

- delay: 00:00:15

Because I would get constant errors with this script after updating Home Assistant. Might it be possible that this script only runs while those services are performing actions?
For example, starts playback, waits 15 seconds, turns up volume, waits 15 seconds, turns up volume (etc), and after last turning up the volume, the script stops (so even though the song is not yet finished, playback will just stop)? If so, what else should I do?

I am going to try adding another delay to the end of the script without any service following it, so that cancelling playback should be postponed for a bit longer. However, if there is a better solution, I would prefer it. For example, instead of my hard-coding a delay value, just finish whatever audio file is currently playing and then stop the script / audio playback.

UPDATE: adding that last delay did nothing. Playback will still stop.

States look like this

volume_level: 0.3 #goes from 0.1 up to 0.3, then will stop soon after that
is_volume_muted: false
media_content_type: music
media_duration: 259 #not sure what this means; the duration of morgen.mp3 is 00:04:18
media_position: 0 #will not update during playback
media_position_updated_at: 2019-09-09T12:22:13.758955+00:00
media_title: morgen.mp3
media_artist: 
media_album_name: 
source_list: TV
shuffle: false
sonos_group: media_player.schlafzimmer_son
night_sound: false
speech_enhance: false
friendly_name: Schlafzimmer Son
supported_features: 64063