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.

2 Likes

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

1 Like

Hi all,

I’m experiencing the same problem. Especially the not continuing on error is very disruptive in scripting. Should I open an issue for this? Or has it been opened yet (and I couldn’t find it)?

Kind regards,
- Ingrid

You might try putting your Sonos commands in a separate script and calling that from the main one. Your continue on error could then be on the script call, rather than the Sonos command.

1 Like

Yes. Please provide a debug log file showing the error happening.

1 Like

I’ll follow up on the issue filed by studioIngrid. Thanks for your help!

Here’s an update.

First the background. In a PR that was merged in 2025.7.0 we added test coverage for join and unjoin; and changed the warning that was logged when the join / unjoin operation timed out to a HomeAssistantError. So the underlying issue likely existed but now that its an exception it is being noticed and affecting automations.

We have two PRs submitted that should fix the join issue.

The main issue is when joining many speakers together; the responses from the speaker arrive in a non-deterministic order essentially overwriting the final state (all are grouped) with an intermediate state (some are grouped). The change in the first PR (Sonos fix media player join to avoid race condition by PeteRager · Pull Request #159106 · home-assistant/core · GitHub) is to add the speakers one by one.

These will be released in 2025.12.4

If you don’t want to wait for the PR; you can change your automation to join each speaker one by one. In other words to join 5 speakers to the main speaker; instead of 1 action listing 5 group members. Create 5 actions each with 1 group member.

alias: SonosJoin
description: ""
actions:
  - action: media_player.join
    continue_on_error: true
    data:
      group_members:
        - media_player.living_room
    target:
      entity_id: media_player.kitchen
  - action: media_player.join
    continue_on_error: true
    data:
      group_members:
        - media_player.master_bedroom
    target:
      entity_id: media_player.kitchen
  - action: media_player.join
    continue_on_error: true
    data:
      group_members:
        - media_player.porcg
    target:
      entity_id: media_player.porch
mode: single

The second issue is under some circumstances the the 5 second timeout is too small. it has been changed to 30 seconds. Sonos increase wait for groups timeout by PeteRager · Pull Request #159108 · home-assistant/core · GitHub

Lastly, I have tested continue_on_error and it works fine. HA still logs the error; but the automation does continue. For example, if I force the timeout to happen every time. This automation does execute the log write action.

alias: SonosJoin
description: ""
actions:
  - action: media_player.join
    continue_on_error: true
    data:
      group_members:
        - media_player.living_room
        - media_player.master_bedroom
        - media_player.porch
    target:
      entity_id: media_player.kitchen
  - action: system_log.write
    data:
      level: error
      message: Next Step Executed
mode: single

We still need a home-assistant.log with debug turned on for the Sonos integration showing the timeout error on a media_player.unjoin. Post it here or create a new GitHub issue.

These issues should be mostly resolved in 2026.1.0. The one fix that has not been released yet is regarding a message with a 9.5 second timeout.