Sonos timeout results in stuck script

I have a script which I trigger via a Google Home device which, among other things, isolates a sonos speaker. This script has been working well for multiple years but has become flakey in the past couple of months. Reading the logs, I see the following error:

2025-09-26 23:43:50.389 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/sonos/media_player.py", line 936, in async_process_unjoin
    await SonosSpeaker.unjoin_multi(
        self.hass, self.config_entry, unjoin_data.speakers
    )
  File "/usr/src/homeassistant/homeassistant/components/sonos/speaker.py", line 1027, in unjoin_multi
    await SonosSpeaker.wait_for_groups(
        hass, config_entry, [[s] for s in speakers]
    )
  File "/usr/src/homeassistant/homeassistant/components/sonos/speaker.py", line 1200, in wait_for_groups
    raise HomeAssistantError(
    ...<3 lines>...
    ) from TimeoutError
homeassistant.exceptions.HomeAssistantError: Timeout while waiting for Sonos player to join the group ['Bedroom: Bedroom']
  1. Thoughts on why simple Sonos operations would suddenly start timing out?
  2. Why does the script fully get stuck running such that when I try to run the script again a full day later, it cannot run because it’s been stuck for 24 hours?
  3. Any suggested workarounds for #2? I tried moving the problematic action to its own script so I could stop that script before each run. But the main script still gets stuck.

Continue on error?

Oooh!! That could be just the thing. Will try.

Though the question maybe remains: why does Home Assistant keep the script running indefinitely when an error like this happens?

Confirmed that continue on error does not help. Also, running another script to stop the running script also does not work.

It seems I am getting timeouts from sonos very regularly. I’ll separately try to understand why that is happening. But would also like to understand more about handling these sorts of errors in script. It seems very strange that the script gets stuck with no apparent recourse except manually stopping it from the UI.

I take it back. script.turn_off does indeed work as expected. The other script I ran to turn off the first script itself had a sonos timeout which prevented it from working. Sigh.

Remaining questions:

  1. Why doesn’t continue_on_error work?
  2. Why am I getting all these Sonos timeouts. :confused:

There’s a bit right at the bottom of the Sonos docs about identifying speakers by their network address.

Sonos maintainer here. Open an issue and I’ll look at it, link it into this topic.

Does the speaker get unjoined properly but the integration is timing out waiting for it?

Provide a home assistant log with debug turned on for Sonos that shows the timeout occurring. Also provide the diagnostics log from before the attempt to unjoin and after the unjoin has timed out.

We had a bunch of issues with joining and unjoining speakers that were resolved several years back. Anyways, the debug log should show us what is happening.

1 Like

Continue on error only continues on errors of type HomeAssistantError, the Sonos integration is throwing a different type of error. It should be updated to through a HomeAssistantError