music-assistant / hass-music-assistant

Turn your Home Assistant instance into a jukebox, hassle free streaming of your favorite media to Home Assistant media players.
Apache License 2.0
1.32k stars 49 forks source link

media_player.media_pause service call leads to an exception on Sonos #2357

Closed gpgmailencrypt closed 3 months ago

gpgmailencrypt commented 4 months ago

What version of Music Assistant has the issue?

2.0.4

What version of the Home Assistant Integration have you got installed?

2024.5.1

Have you tried everything in the Troubleshooting FAQ and reviewed the Open and Closed Issues and Discussions to resolve this yourself?

The problem

The code below in "How to reproduce" is part of an automation. Using it on radios which are off for a longer time leads to an exception

How to reproduce

  1. Make sure the media player is not playing
  2. Wait at least 15 minutes. Sonos seems to go in a kind of standby-mode
  3. Execute the following command
        service: media_player.media_pause
        target:
          entity_id: media_player.radio_schlafzimmer
        data: {}

Music Providers

irrelevant as player isn't playing

Player Providers

Sonos

Full log output

ha.log

Additional information

the media_player.media_stop call doesn't throw an exception

What version of Home Assistant Core are your running

2024.5.4

What type of installation are you running?

Home Assistant Supervised

On what type of hardware are you running?

Linux

marcelveldt commented 3 months ago

Uhm, maybe we should ignore the pause command if the player is not playing but shouldn't you check in your automation/script if the player is actually playing before sending random pause commands while the player is idle ?

marcelveldt commented 3 months ago

Added a small patch in the code to ignore commands to sonos players that are not available, it will be logged though. Still I think it makes sense to not send a pause command to a player if its not playing at all.

OzGav commented 3 months ago

Closing assumed fixed.