home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
69.26k stars 28.47k forks source link

Error on media_player.select_source for Sonos speakers - UPnP Error 402 #117703

Closed ljsquare closed 1 week ago

ljsquare commented 2 weeks ago

The problem

When selecting a source with with service media_player.select_source, you get an UPNP error 402

What version of Home Assistant Core has the issue?

core-2024.5.4

What was the last working version of Home Assistant Core?

core-2024.4

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Sonos

Link to integration documentation on our website

https://www.home-assistant.io/integrations/sonos/

Diagnostics information

No response

Example YAML snippet

service: media_player.select_source
target:
  entity_id: media_player.sonos_move
data:
  source: LOS40

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 2 weeks ago

Hey there @jjlawren, @peterager, mind taking a look at this issue as it has been labeled with an integration (sonos) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `sonos` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign sonos` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


sonos documentation sonos source (message by IssueLinks)

ljsquare commented 2 weeks ago

Addition: When using media_player.play_media you'll get this error: Error calling SonosMediaPlayerEntity._play_media on media_player.sonos_move: UPnP Error 714 received: Illegal MIME-Type from ipaddress

snippet yaml:

service: media_player.play_media
target:
  entity_id:
    - media_player.sonos_move
data:
  media_content_id: LOS40
  media_content_type: music
PeteRager commented 2 weeks ago

That looks like an invalid media content Id. What are you trying to do exactly?

When I run that service call, I get the same error. The error is from Sonos and indicates that the content_id is of an unknown type. So the integration appears to be working as expected when passing in invalid media

PeteRager commented 2 weeks ago

@home-assistant close

ljsquare commented 1 week ago

I'm trying to start my radio (LOS40 is a Spanish radio station). It has worked in earlier versions.

But also when I use the favourite_id, as written in the docs , I get this error: Error calling SonosMediaPlayerEntity._play_media on media_player.sonos_move: UPnP Error 402 received: Invalid Args from

snippet:

service: media_player.play_media
data:
  media_content_id: FV:2/0
  media_content_type: favorite_item_id
target:
  entity_id: media_player.sonos_move
PeteRager commented 1 week ago

Select Source does allow the playing of a favorite by name, so that should work. As should play media using the favorite id (the example you provided is not quoted the same as in the documentation, try putting those strings in quotes)

There is error checking in select source that would log a different error if the favorite does not exist. That isn't happening, so it appear the favorite does exist but the speaker is refusing to play it. UPNP errors are coming from the speaker which means the integration is sending it but the speaker is rejecting it.

PeteRager commented 1 week ago

@home-assistant reopen

PeteRager commented 1 week ago

I just tried this on the dev branch (aka the latest). I added that radio station to my sonos favorites and tried these two service call. They both work fine.

service: media_player.select_source
data:
  source: LOS40
target:
  entity_id: media_player.living_room

and i tried it using the favorite id (my id may be different than yours)

service: media_player.play_media
target:
  entity_id: media_player.living_room
data:
  media_content_type: "favorite_item_id"
  media_content_id: "FV:2/16"
ljsquare commented 1 week ago

Select Source does allow the playing of a favorite by name, so that should work. As should play media using the favorite id (the example you provided is not quoted the same as in the documentation, try putting those strings in quotes)

There is error checking in select source that would log a different error if the favorite does not exist. That isn't happening, so it appear the favorite does exist but the speaker is refusing to play it. UPNP errors are coming from the speaker which means the integration is sending it but the speaker is rejecting it.

  • double check the favorite still exists in the Sonos App
  • Are you able to play it from the Sonos app?
  • Try power cycling the speaker.
  • Try deleting the favorite in the Sonos app, re-adding and restart HA
  • Provide the text content of the Sonos favorite entity (grab it from developers tools)

It works from the Sonos App and I already power cycled the speaker. I'll try to delete the favourite in the Sonos app and try it again.

ljsquare commented 1 week ago

The problem lays with the new Sonos app. Old favourites won't work either in the sonos app or HA. When deleting the old one and creating a new favourite, it works like it should be.