core: Sonos devices keep becoming unavailable

The problem

Since version 2023.2, I have found many of my speakers show “Subscription renewal failed” messages After switching on debugging I get additional messages such as

2023-02-15 16:44:15.258 DEBUG (MainThread) [soco.events_base] 412, message='Precondition Failed', url=URL('http://10.87.2.104:1400/MediaServer/ContentDirectory/Event')
2023-02-15 16:44:15.268 WARNING (MainThread) [homeassistant.components.sonos.speaker] Subscription renewal failed for Garage: 412, message='Precondition Failed', url=URL('http://10.87.2.104:1400/MediaServer/ContentDirectory/Event')
2023-02-15 16:44:15.274 DEBUG (MainThread) [homeassistant.components.sonos.speaker] Starting resubscription cooldown for Garage
2023-02-15 16:44:15.277 DEBUG (MainThread) [homeassistant.components.sonos.speaker] Unsubscribing from events for Garage
2023-02-15 16:44:15.286 DEBUG (MainThread) [soco.events_base] 412, message='Precondition Failed', url=URL('http://10.87.2.104:1400/MediaRenderer/AVTransport/Event')
2023-02-15 16:44:15.288 DEBUG (MainThread) [soco.events_base] 412, message='Precondition Failed', url=URL('http://10.87.2.104:1400/MediaRenderer/RenderingControl/Event')
2023-02-15 16:44:15.290 DEBUG (MainThread) [soco.events_base] 412, message='Precondition Failed', url=URL('http://10.87.2.104:1400/ZoneGroupTopology/Event')

This is most noticeable when it is affecting the speaker I user in the media-control card, as it ‘blanks’ for a while, and normally after a minute or two, it fixes itself. Then the whole cycle repeats.

My setup is a bit non-standard as I run HASS on a different vlan/subnet to the speakers. Discovery and firewalls have been set up to handle this, and up to 2023.1.7, everything worked fine. And backing out to 2023.1.7 works fine, so I don’t think it is a setup issue.

As a further test I set up HASS on a new machine on the same vlan/subnet as my main instance, with just the Sonos integration, and it does NOT exhibit the same behaviour. This seems odd, so I guess it is either a timing or load related issue with my main HASS instance. I doubt my installation ranks as overly complex (‘state_count’: 1154, ‘automation_count’: 261, ‘integration_count’: 88), and the load on the machine is low.

Something in the 2023.2 release clearly changed the subscription behaviour or timing. Perhaps someone in the know can shed some light on this…

I’m happy to install and test on newer versions, but cannot leave current versions on my live system as it breaks stuff, so will have to revert to 2023.1.7 after testing.

Is there anything I can extract from the debug log file that I saved to assist?

What version of Home Assistant Core has the issue?

2023.2.x

What was the last working version of Home Assistant Core?

2023.1.7

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Sonos

Link to integration documentation on our website

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

Diagnostics information

Unfortunately I get a 500 error in the diagnostics file, probably because it runs behind a reverse proxy, I will try to fix this

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 2
  • Comments: 41 (7 by maintainers)

Most upvoted comments

I am continuing to see this problem intermittently with all of my Sonos speakers. It seems a reboot of HA will immediately restore the connection to the unavailable speaker(s); and if I don’t reboot HA then the speaker(s) usually and eventually (time seems to vary) will reconnect to HA on its own. Meanwhile, there is no issue controlling the speaker from the Sonos App.