Why Sonos speaker is unavailable?

As title suggest I am having trouble with Sonos speaker (from IKEA) becoming unavailable in HA. I am using official Sonos integration.

Any help or suggestion how to troubleshoot it is appreciated.

From logs I see:

2024-01-03 15:34:31.480 WARNING (MainThread) [homeassistant.components.sonos.speaker] No recent activity and cannot reach Kitchen, marking unavailable

But I don’t see how to extend this period or how to disable this behaviour.

The log message suggests your Kitchen speaker is experiencing a Wi-Fi connection problem. It’s dropping off the network, Home Assistant’s Sonos integration has given up trying to connect to it and marked it as unavailable.

You’ll need to check your Wi-Fi network and determine why the speaker is losing connection.

Ok so it really looks like there was some problem with network (I can see it also in speedTest graphs). So now how to make it that HA will try to ping Sonos for longer or will recover after network issue?

If you look at the documentation for the Sonos integration, and the available configuration options displayed in the UI (Settings > Devices & services > Integrations > Sonos), there’s nothing available to control that aspect of its operation.

Yeah I tried to check docs and without luck as you mentioned. That’s why I created this post, if anybody has any different solution for this.

I don’t like to be removing and adding speaker to HA just because it lost network for couple moments. That is kinda stupid in my opinion :grinning:.

If my Wi-Fi network is turned off, my Sonos speakers are marked unavailable but moments after the network is re-established, the speakers are no longer unavailable (they automatically return to idle or paused).

Go to Settings > Devices & services > Integrations > Sonos > Configure and check your settings:

image

I have those 2 set the same.

In meantime I created small automation which might help me

alias: Reload Kitchen speaker
description: ""
trigger:
  - platform: state
    entity_id:
      - media_player.kitchen
    from: null
    to: unavailable
    for:
      hours: 0
      minutes: 1
      seconds: 0
condition: []
action:
  - service: homeassistant.reload_config_entry
    target:
      entity_id: media_player.kitchen
    data: {}
  - service: notify.persistent_notification
    data:
      message: Kitchen speaker unavailable. Trying to reload config
mode: single

But it was also strange that I was able to play music on the speaker (from smartphone) but it was still unavailable in HA.

1 Like

It implies that there may not be a general Wi-Fi network problem and your speaker is not disconnecting from the network, or at least not for very long and quickly re-connects.

The problem may be limited to your Home Assistant server’s ability to detect the speaker after a brief interruption in network connectivity.

If reloading the Sonos integration makes it detect the speaker again, it implies the integration is able to detect the speaker but only on reload. I suggest you report this as an Issue in Home Assistant’s Github Core repository. The author of the Sonos integration would probably be interested to learn about this particular behavior (and may be able to either shed light on the cause or modify the integration to mitigate the issue).

2 Likes

I was about to reply here with reference to already open issue

And thanks for all your efforts. Really appreciate it.

It appears to be a long-standing issue with no resolution.

You may wish to provide jjlawren with debug logs for the Sonos integration (when the disconnection occurs) to help shed more light on the cause of the problem.

logger:
  default: warning
  logs:
    homeassistant.components.sonos: debug

Good luck.

I never done log debugging with HA. So if you have some time I would appreciate your help with it.

Where should I put config you shared above? To configuration.yaml? Should I put it there or after disconnect? Is restart of HA needed? If I put it now won’t my disk fill up with logs quickly?

To get log in my first message I went to Sonos integration and enable and disable “Enable debug logging” witch after disabling downloaded log file and I have there the occurrence of disconnecting, but it looks like there is also a lot different logs. Si not sure if I should attached it or filter it first only for Sonos.

Thanks

That’s more convenient than what I had suggested.

I would leave everything it as-is and attach it to the new Issue you will create in Home Assistant’s GitHub Core repository.

1 Like

Just for reference

Try connecting each Sonos amp with ethernet to the switch. This fixed the problem for me.

I think I saw your comment on GitHub. But that is still not the solution. For example I am not able to get cable to my speaker. And I would expect it to work on WiFi as well. I mean it is good to know that this fix it for you but it is still just workaround for deeper issue, I believe

Based on your logs the HA computer is unable to connect to that device. Perhaps there is a firewall issues, a routing issue, or something else.

YMMV. The problem I was having was that when power was restored, it could take over an hour for a device to be visible, and hence controllable, in HA, even though it worked in the Sonos app within a few seconds and hence was clearly “on.” I had one amp hard-wired to the switch and the rest relying on Sonos’s wireless connections, which at a minimum creates interdependencies. BTW it wasn’t just HA – Ubiquiti also didn’t see the devices for the same amount of time, though Ubiquiti isn’t 100% reliable at reporting devices that have DHCP connections.

I gather wifi 7 is focused on increased reliability; perhaps it will fix such common problems, at least for devices made after 2025.