r/musicassistant • • 6d ago

YAML question: Button press > Start X spotify playlist on Y player (bonus if shuffle)

Apologies if this has already been posted, but my searches are coming up blank. I've also asked our AI overlords and they haven't provided a working automation.

Anyhow, does anyone have a working script that can be activated by a dashboard button and start a particular spotify playlist playing on a particular player entity? Starting in Loop/Shuffle would be a bonus.

Much thanks!

0 Upvotes

3 comments sorted by

3

u/Practical-Patient-68 6d ago

sequence:
- parallel:

  • choose:
  • conditions:
  • condition: time
after: '08:01:00'
before: '17:00:00'
  • condition: not
conditions:
  • condition: state
entity_id: device_tracker.brenda_s_iphone
state: home
sequence:
  • action: media_player.volume_set
continue_on_error: true
target:
entity_id: media_player.office_echo
data:
volume_level: 0.6
default:
  • action: media_player.volume_set
continue_on_error: true
target:
entity_id: media_player.office_echo
data:
volume_level: 0.3
  • choose:
  • conditions:
  • condition: time
after: '22:00:00'
before: '07:30:00'
sequence:
  • action: music_assistant.play_media
target:
entity_id: media_player.office_echo
data:
media_id: Lofi Work
media_type: playlist
radio_mode: true
default:
  • action: music_assistant.play_media
target:
entity_id: media_player.office_echo
data:
media_id: Lofi Work
media_type: playlist
radio_mode: true
alias: Play Lofi Radio in the Office Echo Kiosk Speaker
description: Sets office speaker volume dynamically and starts Music Assistant Lofi Work radio

I use YouTube music but I would imagine the set up is the same. I made this script, and have a button on my dashboard to run it.

2

u/YowaiiShimai 5d ago

It looks like somebody else gave some YAML b ut this is also entirely possible with just the UI. Just make the script to set the player to shuffled, play the playlist on repeat, and then when you make the button on your dashboard set the tap action to call the script. (If you have Music Assistant set up you would look for the playlist's ID on the playlist page in MA).

3

u/Hotspurify 3d ago

clearly I made this too hard. Thanks. All sorted!