#Pause and play for music assistant

1 messages · Page 1 of 1 (latest)

proper ledge
#

Hi,
I am trying to create an automation where I try to mimic "musical statues". So I start by playing calling the music assistant action to play a Spotify playlist. I then wait for a few seconds and then pause it. However when I try to resume it, it starts playing from the beginning again.
From reading a bit on music assistant, it appears a new queue is created each time one plays. Is it possible to play and pause music assistant using automations in the way I want or do I need to create another solution?

proper ledge
# proper ledge Hi, I am trying to create an automation where I try to mimic "musical statues". ...

Automation:

alias: Vardagsrum - Styr dansstopp
description: ""
triggers:
  - trigger: state
    entity_id:
      - input_boolean.vardagsrum_dansstopp
    to: "on"
    id: Dansstopp på
  - trigger: state
    entity_id:
      - input_boolean.vardagsrum_dansstopp
    to: "off"
    id: Dansstopp av
conditions: []
actions:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - Dansstopp på
        sequence:
          - action: script.turn_on
            metadata: {}
            data: {}
            target:
              entity_id: script.vardagsrum_dansstopp
      - conditions:
          - condition: trigger
            id:
              - Dansstopp av
        sequence:
          - action: media_player.turn_off
            metadata: {}
            data: {}
            target:
              device_id: 454d07fb0ef251e1d0ff6268799778b0
          - action: script.turn_off
            metadata: {}
            data: {}
            target:
              entity_id: script.vardagsrum_dansstopp
mode: single```
#

Script:

sequence:

  • repeat:
    sequence:
    - action: media_player.volume_set
    metadata: {}
    data:
    volume_level: 0.14
    target:
    device_id: 454d07fb0ef251e1d0ff6268799778b0
    - action: music_assistant.play_media
    metadata: {}
    data:
    media_id: >-
    https://open.spotify.com/playlist/5ATjqESEpwPPdXe0c2Zn80?si=XjnauDV8SguMik1XMrmWuA&pi=W6Z1I__PS56UQ
    target:
    device_id:
    - 454d07fb0ef251e1d0ff6268799778b0
    - delay: "{{ range(0, 20)|random }}"
    - action: media_player.media_play_pause
    metadata: {}
    data: {}
    target:
    device_id: 454d07fb0ef251e1d0ff6268799778b0
    - delay: "3"
    - action: media_player.media_play_pause
    metadata: {}
    data: {}
    target:
    device_id: 454d07fb0ef251e1d0ff6268799778b0
    while:
    - condition: state
    state: "on"
    entity_id: input_boolean.vardagsrum_dansstopp
    alias: Vardagsrum - Dansstopp
    description: ""
lusty sableBOT
#

To format your text as code, enter three backticks on the first line, press Enter for a new line, paste your code, press Enter again for another new line, and lastly three more backticks.
```yaml
example: here
```
Don't forget you can edit your post rather than repeatedly posting the same thing.

lapis rock
#

As above you need to format your code so it is readable. Yes you can do what you want. New queues are not created on play/pause. You dont say what version of the server you are running nor what player provider you are using.