Sonos integration functionality

Hello. After the wave of new features, I’m retesting Gladys, which I’ve been keeping an eye on for quite some time. I started by trying to integrate my Sonos speakers, and it seems that it doesn’t work because the speakers are on a dedicated VLAN, separate from the one where Gladys is running? Has anyone managed to make it work with this configuration? The scan doesn’t return any results, and as far as I can tell, there’s no way to specify the IPs of the speakers?

Thanks!

Hello,

I have the same issue on my end :innocent:

Hi,

I think you need to enable the mdns protocol between your VLANs (Sonos and Gladys) on your router.

I thought I understood that the Sonos integration doesn’t use mDNS?

Hi, maybe so, but there must be some kind of automatic discovery protocol?

Hi,

Yes, that seems consistent with your network configuration.

The current Sonos integration in Gladys uses automatic SSDP/UPnP discovery. It therefore sends a multicast request on 239.255.255.250:1900.

https://sonos.svrooij.io/sonos-communication

With Gladys and the Sonos devices placed on two different VLANs, this multicast generally does not traverse the router by default. The scan may therefore find nothing even if Gladys is allowed to communicate directly with the IP addresses of the speakers.

And indeed, looking at the current integration, the scan only goes through InitializeWithDiscovery(): it does not seem possible in Gladys to manually enter the IP address of a speaker.

However, the Sonos library used by Gladys allows starting from a known device rather than just doing network discovery. This could therefore be an interesting evolution of the integration: allowing to manually enter the IP address of a Sonos for installations with VLANs.

In the short term, the other solution would be to configure the network to correctly relay SSDP between the two VLANs.

@David I’m going to work on Sonos externally to add management of known IPs, plus playback by URI. (The rest will be identical to the native version :slight_smile:
I’ll need you to test it @prohand you’re also welcome to join :slight_smile:

With pleasure :winking_face_with_tongue:

@prohand @David

Tell me if you find your Sonos with this :slight_smile:

https://ghcr.io/vincentbesseau/gladys-sonos:0.1.1

{
  "manifest_version": 1,
  "type": "device",
  "name": "Sonos",
  "description": {
    "en": "Control Sonos speakers locally, including VLAN setups, and play any content URI.",
    "fr": "Contrôlez vos enceintes Sonos en local, y compris en VLAN, et lancez n'importe quelle URI."
  },
  "version": "0.1.1",
  "docker_image": "ghcr.io/vincentbesseau/gladys-sonos:0.1.1",
  "gladys_version": ">=4.86.0",
  "cover_image": "https://raw.githubusercontent.com/vincentBesseau/gladys-sonos/main/cover.jpg",
  "categories": [
    "multimedia"
  ],
  "transports": [
    "local"
  ],
  "network_discovery": [
    {
      "type": "ssdp",
      "st": "urn:schemas-upnp-org:device:ZonePlayer:1"
    }
  ],
  "config_schema": [
    {
      "key": "intro",
      "type": "section",
      "label": {
        "en": "Sonos, controlled locally",
        "fr": "Sonos, piloté en local"
      },
      "description": {
        "en": "This integration controls your Sonos speakers directly over your local network - no cloud account, no Sonos app login. It discovers them automatically (SSDP). If your Sonos speakers are on a different VLAN/subnet than Gladys, automatic discovery will not find them: fill in one known IP below instead, it is enough to recover the whole household.",
        "fr": "Cette intégration pilote vos enceintes Sonos directement sur votre réseau local - aucun compte cloud, aucune connexion à l'app Sonos. Elle les découvre automatiquement (SSDP). Si vos enceintes Sonos sont sur un VLAN/sous-réseau différent de Gladys, la découverte automatique ne les trouvera pas : renseignez plutôt une IP connue ci-dessous, cela suffit à retrouver toute l'installation."
      }
    },
    {
      "key": "known_ips",
      "type": "string",
      "label": {
        "en": "Known IPs (VLAN fix)",
        "fr": "IPs connues (contournement VLAN)"
      },
      "description": {
        "en": "One Sonos speaker IP is enough: this integration then asks it for your whole household's layout. Separate multiple entries with a comma or a new line.",
        "fr": "L'IP d'une seule enceinte Sonos suffit : l'intégration lui demande ensuite l'organisation de toute votre installation. Séparez plusieurs entrées par une virgule ou un retour à la ligne."
      },
      "placeholder": {
        "en": "192.168.10.21",
        "fr": "192.168.10.21"
      }
    }
  ],
  "actions": [
    {
      "key": "scan_now",
      "label": {
        "en": "Scan for Sonos speakers",
        "fr": "Rechercher les enceintes Sonos"
      },
      "timeout_seconds": 30
    }
  ]
}

After having to open port 1400 in TCP, I now have my 2 Sonos speakers:

I haven’t been able to test it yet because the kids are sleeping :innocent:

They have the same name here, but I checked in the Sonos app and it’s the same. I’ll have to look into why later :sweat_smile:

Thanks for the dev :wink:

Super, I’m waiting for @David’s feedback :slight_smile:

@pierre-gilles Do you think it’s better if I make a PR to gladys? Or should we mark Sonos as deprecated natively?
For info, I added two additional fields to Sonos (current music) and play URI. The other change is the addition of known IPs for the VLANs

Hello,

On my end, discovery doesn’t work with a simple scan, but it does work by specifying the IPs of the speakers, even from another VLAN. However, it gives me the text function twice? and doesn’t provide as many settings as the HA integration (bass loudness, etc).

The now playing feature also works, but it displays the speaker name twice. And otherwise, I have the correct name for all the speakers. However, I don’t understand what the play URI function is for.

No worries, he has two text functions, it’s normal: play uri and current song

And what you see in duplicate is the operation of the gladys device (function)

@pierre-gilles It’s not so simple for someone coming from HA

The other features may come later, I’ll look into it. Let’s take it easy ^^

You can pass it a URI like a Spotify link via a scene.

I made a PR on Spotify to access certain data, so let’s be patient ^^

That way, via a scene, we’ll be able to play a playlist, a song, etc.

That’s not bad, that would allow sending a gentle wake-up playlist in the morning…

Anyway, I had an issue yesterday and today it’s fixed. You can’t say my patience was tested! A big thank you! I’m at your disposal if I can help, with pleasure.

Sonos internal should be deprecated in favor of an external integration