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
71.17k stars 29.85k forks source link

Sonos Restore reporting UPnP Error 402 received: Invalid Args from <IP ADDR> #76950

Open dgrove opened 2 years ago

dgrove commented 2 years ago

The problem

(This appears to be related to https://github.com/home-assistant/core/pull/50575 , which fixed a similar issue quite awhile ago).

When using "sonos.restore" to bring back the state of a previously-backed-up Sonos entity, I am getting this error:

-- Logger: homeassistant.components.sonos.speaker Source: components/sonos/speaker.py:1039 Integration: Sonos (documentation, issues) First occurred: 12:24:35 PM (1 occurrences) Last logged: 12:24:35 PM

Error on restore Main Room: UPnP Error 402 received: Invalid Args from 192.168.86.29

A few specific details:

What version of Home Assistant Core has the issue?

2022.8.5

What was the last working version of Home Assistant Core?

No response

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

config_entry-sonos-ea070f37f617c21e991b50d495b787b4.json.txt

Example YAML snippet

alias: Doorbell Pressed -> Chime on Sonos
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.front_door_button_pressed
    to: "on"
condition: []
action:
  - service: sonos.snapshot
    data:
      entity_id: all
      with_group: false
  - service: media_player.volume_set
    data:
      volume_level: 0.37
    target:
      entity_id: media_player.main_room_sonos
  - service: media_player.play_media
    data:
      media_content_type: music
      media_content_id: http://192.168.86.61:8123/local/doorbell_chime.mp3
    target:
      entity_id: media_player.main_room_sonos
  - delay:
      hours: 0
      minutes: 0
      seconds: 4
      milliseconds: 0
  - service: sonos.restore
    data:
      entity_id: all
      with_group: false
mode: single

Anything in the logs that might be useful for us?

No response

Additional information

No response

probot-home-assistant[bot] commented 2 years ago

sonos documentation sonos source (message by IssueLinks)

probot-home-assistant[bot] commented 2 years ago

Hey there @cgtobi, @jjlawren, 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! (message by CodeOwnersMention)

brhahlen commented 2 years ago

Same happens here, following

skellycode commented 2 years ago

Same Issue - following

jjlawren commented 2 years ago

I believe this is a limitation of what media sources the underlying library can restore. If media playback is started from a Spotify app (and not from selecting Spotify media within in the Sonos app), then the media stream is "owned" by Spotify and is effectively an externally managed stream. As of now there doesn't seem to be a way to snapshot/resume those using the native Sonos APIs. I hope that I'm wrong as I don't use Spotify much myself, but that's my guess as of right now.

brhahlen commented 2 years ago

I'm not sure, because for me it happens when playing a TuneIn Radio stream, that is started from Sonos itself.

It used to work without issue, I'm really sure of that :)

trackd commented 1 year ago

+1 I've had some success restoring playback from Sonos radio, but very limited testing as it's not something i use.

but cannot restore spotify, neither when started from the spotify app or when started from the sonos app.

I'm guessing that restore when playing from the spotify app might be impossible. as @jjlawren said.

But should be possible when starting spotify music from the sonos app?

jjlawren commented 1 year ago

I wish this all worked cleanly and I didn't have to recommend this, but that's why I created https://github.com/jjlawren/sonos_cloud. This uses a Sonos cloud API which is the only way to trigger "overlay" alerts on top of the currently playing music without going through the snapshot/restore dance. It is not a replacement for the built-in Sonos integration.

Talvish commented 1 year ago

I'm seeing this issue as well (currently testing Spotify, haven't tested any radio streams). Hard to nail down all conditions, but it seems if I START from Alexa on the Sonos or I use the Spotify app, then it gets into this condition.

It works fine if I start from the Sonos mobile app. It also works if I start from the Sonos app, and use Alexa and say 'pause music' followed by 'resume music' (and cause a snapshot/resume after that). But if I use Alexa to say 'play music' instead of 'resume music' then it doesn't work. No doubt that the Sonos speakers are storing state separately by how you start music.

I swear at least some of these conditions use to work, but I can't be 100% certain. Is this an unsurmountable problem?

NodeJames commented 1 year ago

I'm also having the issue with starting music on the Spotify app, either on iOS app or on my Macbook. It won't continue playing after a notification is read aloud. I can happily use the Sonos app in place, but I know other family members aren't going to buy in. I was hoping to find a way to have a door open chime play over the speakers, but that won't work during parties if a friend is using their Spotify app to stream tunes. Although, I'll probably want a party mode that disables that entirely.

I use sonos AMP's for whole house audio. There's a few alexa's around the house, so I'll probably resort to using those for announcing things. Maybe I can get it to announce things to Alexa when music is playing over Sonos, so it doesn't interrupt.

jjlawren commented 1 year ago

This is a limitation of the Sonos API when working with Spotify (and certain other music services).

For (far) better Sonos alert/TTS handling, I'd currently recommend my Sonos Cloud custom component as mentioned above. I'd like to integrate these features into the standard integration eventually, but for now it's separate.

canedje commented 1 year ago

Same over here

jamess5 commented 1 year ago

Also getting this issue now - suddently occurring

saschachina commented 1 year ago

Same here...

Logger: homeassistant.components.sonos.speaker
Source: components/sonos/speaker.py:1061
Integration: Sonos (documentation, issues)
First occurred: 12. März 2023 um 19:40:45 (6 occurrences)
Last logged: 13. März 2023 um 21:54:28

Error on restore Wohnzimmer: UPnP Error 701 received: Transition not available from 192.xxx.1.xxx
issue-triage-workflows[bot] commented 1 year ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

brhahlen commented 1 year ago

Issue is still present:

Logger: homeassistant.components.sonos.speaker
Source: components/sonos/speaker.py:1080
Integration: Sonos (documentation, issues)
First occurred: 11 June 2023 at 15:41:56 (4 occurrences)
Last logged: 20:00:13

Error on restore Living Room: UPnP Error 402 received: Invalid Args from 192.168.X.X

Home Assistant 2023.6.1 Frontend 20230608.0 - latest

jjlawren commented 1 year ago

As of 2023.5, the Sonos integration now has support for announce handling. Try to use media_player.play_media with announce: true or any TTS announcement when music is playing (even Spotify)--you no longer need to snapshot/restore/regroup.

skellycode commented 1 year ago

As of 2023.5, the Sonos integration now has support for announce handling. Try to use media_player.play_media with announce: true or any TTS announcement when music is playing (even Spotify)--you no longer need to snapshot/restore/regroup.

Thank you @jjlawren - I can confirm this is indeed resolved (tested on 2023.6.1).

I've migrated everything over to the announce syntax per the docs which has enabled me to remove ~300 lines of 'snapshot dance' yaml from my scripts!!! Happy days! 🥳

brhahlen commented 1 year ago

I just applied this as well, thanks for the pointers!

issue-triage-workflows[bot] commented 1 year ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

brhahlen commented 1 year ago

Issue is still present

brhahlen commented 1 year ago
Logger: homeassistant.components.automation.sonos_lr_play_morning_music
Source: components/automation/__init__.py:680
Integration: Automation (documentation, issues)
First occurred: 06:00:02 (1 occurrences)
Last logged: 06:00:02

Error while executing automation automation.sonos_lr_play_morning_music: Error calling SonosMediaPlayerEntity.select_source on media_player.living_room: UPnP Error 402 received: Invalid Args from 192.168.2.142
issue-triage-workflows[bot] commented 9 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

brhahlen commented 9 months ago

Issue still present.

2023-12-11 06:00:04.227 ERROR (MainThread) [homeassistant.components.automation.sonos_lr_play_morning_music] Sonos - LR - Play Morning Music: Error executing script. Error for call_service at pos 5: Error calling SonosMediaPlayerEntity.select_source on media_player.living_room: UPnP Error 402 received: Invalid Args from 192.168.2.142
2023-12-11 06:00:04.231 ERROR (MainThread) [homeassistant.components.automation.sonos_lr_play_morning_music] Error while executing automation automation.sonos_lr_play_morning_music: Error calling SonosMediaPlayerEntity.select_source on media_player.living_room: UPnP Error 402 received: Invalid Args from 192.168.2.142
issue-triage-workflows[bot] commented 6 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

brhahlen commented 6 months ago

Still happens intermittently

fhb commented 3 months ago

To me this error was shown, because i needed to reauthorize the tunein account, so it is probably usually an issue caused by the sonos system not being able to play/find the media, not a homeassistant integration issue.

issue-triage-workflows[bot] commented 2 weeks ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

glucaci commented 1 week ago

keep-it