soco.discovery module

This module contains methods for discovering Sonos devices on the network., include_invisible=False, interface_addr=None)[source]

Discover Sonos zones on the local network.

Return a set of SoCo instances for each zone found. Include invisible zones (bridges and slave zones in stereo pairs if include_invisible is True. Will block for up to timeout seconds,

System Message: ERROR/3 (/home/docs/checkouts/ of, line 6)

Unexpected indentation.
after which return None if no zones found.
  • timeout (int, optional) – block for this many seconds, at most. Defaults to 5.
  • include_invisible (bool, optional) – include invisible zones in the return set. Defaults to False.
  • interface_addr (str or None) – Discovery operates by sending UDP multicast datagrams. interface_addr is a string (dotted quad) representation of the network interface address to use as the source of the datagrams (i.e. it is a value for socket.IP_MULTICAST_IF). If None or not specified, the system default interface for UDP multicast messages will be used. This is probably what you want to happen. Defaults to None.

a set of SoCo instances, one for each zone found, or else


Return type:



There is no easy cross-platform way to find out the addresses of the local machine’s network interfaces. You might try the netifaces module and some code like this:

>>> from netifaces import interfaces, AF_INET, ifaddresses
>>> data = [ifaddresses(i) for i in interfaces()]
>>> [d[AF_INET][0]['addr'] for d in data if d.get(AF_INET)]
['', '']

This should provide you with a list of values to try for interface_addr if you are having trouble finding your Sonos devices


Return any visible soco device, for when it doesn’t matter which.

Try to obtain an existing instance, or use discover if necessary. Note that this assumes that the existing instance has not left the network.

A SoCo instance (or subclass if config.SOCO_CLASS is set,
or None if no instances are found
Return type:SoCo

Return a device by name.

Parameters:name (str) – The name of the device to return.
The first device encountered among all zone with the
given player name. If none are found None is returned.
Return type:SoCo