Script for media player doesn't work but why?

I tried many things but I just don’t understand why the script

'1542806218565':
  alias: Wolfgangs Favorites
  sequence:
  - data:
      entity_id: media_player.wohnzimmer
      shuffle: 'true'
      source: Wolfgangs all-time favorites
    service: media_player.select_source

doesn’t do anything. When I take out the “Shuffle” it works but I want the playlist shuffled. I triggers a Sonos media player.

Obvious mistake?

According to the media_player docs, select_source and shuffle_set are two different services. Maybe:

'1542806218565':
  alias: Wolfgangs Favorites
  sequence:
  - data:
      entity_id: media_player.wohnzimmer
      source: Wolfgangs all-time favorites
    service: media_player.select_source
  - data:
      entity_id: media_player.wohnzimmer
      shuffle: true
    service: media_player.shuffle_set
1 Like

This works. Thanks Phil!

The only thing that isn’t perfect yet is that the playlist will always start with the same song. After that it shuffles. So, maybe I’ll put a “stop playing” after the first command, do the “shuffle” and then “start playing” again.

Hmm, that does the shuffle right but it doesn’t start playing.

'1542806218565':
  alias: Wolfgangs Favorites
  sequence:
  - data:
      entity_id: media_player.wohnzimmer
      source: Wolfgangs all-time favorites
    service: media_player.select_source
  - data:
      entity_id: media_player.wohnzimmer
    service: media_player.media_stop
  - data:
      entity_id: media_player.wohnzimmer
      shuffle: 'true'
    service: media_player.shuffle_set
  - data:
      entity_id: media_player.wohnzimmer
    service: media_player.play_media

Maybe too many commands in fast sequence?

Well, this is weird. When I add a delay command the script is changed into a switch in the lovelace frontend.

'1542806218565':
  alias: Wolfgangs Favorites
  sequence:
  - data:
      entity_id: media_player.wohnzimmer
      source: Wolfgangs all-time favorites
    service: media_player.select_source
  - data:
      entity_id: media_player.wohnzimmer
    service: media_player.media_stop
  - data:
      entity_id: media_player.wohnzimmer
      shuffle: 'true'
    service: media_player.shuffle_set
  - delay: 'seconds: 2'
  - data:
      entity_id: media_player.wohnzimmer
    service: media_player.play_media

It’s not weird, it’s what is supposed to happen, so you can stop it running during the delay if you need to.

Ah, thanks @anon43302295. Is there a way to change this behavior? It’s a delay of a few seconds, I don’t need the option to stop the execution of the script.

Sure, under your customize: put

script.NAME_OF_SCRIPT:
  can_cancel: false
1 Like

You’re the master. Thanks!

1 Like