Sonos does not listen to mediaplayer.stop

Hi!

I am running a script with multiple actions. te latest action is a mediaplayer.stop targeted to all my sonos systems.

Now, most of the times this works fine. when i fire this specific action in the script my HA always poops out this error: CastMediaPlayerEntity.media_stop Failed: Failed to execute stop.

This results in sometimes one (or more) sonos speakers not stopping the music played.

googling only gives me information that i should have used the correct action for the job but no actual solution to my problem :confused:

we mostly use the sonos to play a radio station via the sonos app or tunein.

here is the full script in yaml:

sequence:
  - action: light.turn_off
    metadata: {}
    data: {}
    target:
      entity_id: light.nighty_night_targeted_lights_group
  - device_id: 233948172fb2af41aff2aaa4f4090006
    domain: lock
    entity_id: 8742ae5af4ebd5843ca1f4ad83466f6f
    type: lock
  - action: vacuum.return_to_base
    metadata: {}
    data: {}
  - action: media_player.media_stop
    metadata: {}
    target:
      label_id: alle_speakers
    data: {}
alias: Nighty Night
description: ""

can someone help me out?

Hi Tim, just a few ideas.

What happens if you only execute that command to stop the media players? (in the script or in the development tools → actions?
I have experienced that sometimes adding a small time delay before a step that was not working consistently could solve this.

What the real cause of your issue is I can’t say so maybe with this workaround you can at least solve it for now.

Hi Nick,

thats the moment when i get the error: CastMediaPlayerEntity.media_stop Failed: Failed to execute stop.

And i have tried to build 500 Milliseconds of delay in the script before executing the sonos command but still no joy

I have no clue about the reason but a few more ideas:

  • what if you address the players individually instead of a group?
  • use media_player.turn_off to see what happens?

when i use media_player.turn_off i can’t even target my sonos devices as target. only a google nest speaker.

Like this you should be able:

action: media_player.turn_off
data: {}
target:
  entity_id:
    - media_player.1
    - media_player.2

When i throw your example in the YAML like this:

sequence:
  - action: light.turn_off
    metadata: {}
    data: {}
    target:
      label_id: lampen_nachtstand
  - device_id: 233948172fb2af41aff2aaa4f4090006
    domain: lock
    entity_id: 8742ae5af4ebd5843ca1f4ad83466f6f
    type: lock
  - action: vacuum.return_to_base
    metadata: {}
    data: {}
  - action: media_player.turn_off
    data: {}
    target:
    entity_id:
      - media_player.kantoor_speaker
      - media_player.woonkamer_speaker
      - media_player.eetkamer_speaker
alias: Nachtstand
description: Zet verschillende apparaten in en om het huis in de nachtstand

I get this error:

Message malformed: expected a dictionary for dictionary value @ data[‘sequence’][3][‘target’]

nevermind, forgot the TAB :slight_smile:

but when i trigger that one action in the script i get this:

Entity media_player.kantoor_speaker does not support action media_player.turn_off

What about media_player.pause

Strange…
From the Sonos integration

What if you try them one by one?
And for the test it’s easier to do this with Actions under ‘Development tools’.

Sonos does not have a turn off command. It has pause and stop. If those don’t work directly from an action is developer tools submit an issue (with a debug log) and I’ll look at it.

The CastMediaPlayerEntity is not a Sonos speaker.

        MediaPlayerEntityFeature.BROWSE_MEDIA
        | MediaPlayerEntityFeature.CLEAR_PLAYLIST
        | MediaPlayerEntityFeature.GROUPING
        | MediaPlayerEntityFeature.MEDIA_ANNOUNCE
        | MediaPlayerEntityFeature.MEDIA_ENQUEUE
        | MediaPlayerEntityFeature.NEXT_TRACK
        | MediaPlayerEntityFeature.PAUSE
        | MediaPlayerEntityFeature.PLAY
        | MediaPlayerEntityFeature.PLAY_MEDIA
        | MediaPlayerEntityFeature.PREVIOUS_TRACK
        | MediaPlayerEntityFeature.REPEAT_SET
        | MediaPlayerEntityFeature.SEEK
        | MediaPlayerEntityFeature.SELECT_SOURCE
        | MediaPlayerEntityFeature.SHUFFLE_SET
        | MediaPlayerEntityFeature.STOP
        | MediaPlayerEntityFeature.VOLUME_MUTE
        | MediaPlayerEntityFeature.VOLUME_SET
    )
 

Hi, thanks for jumping in and sharing this info about the off command, or better the lack of.
This would mean that the documentation for the integration should be updated.

Yep, we should create an issue here GitHub - home-assistant/home-assistant.io: 📘 Home Assistant User documentation