This section will help you to quickly get started with SoCo.
From PyPi with pip
pip install soco
This will automatically take care of installing any dependencies you need.
Manual installation from .tar.gz file
SoCo can also be installed manually from the .tar.gz file. First, find the
latest version of SoCo on PyPi and
.tar.gz file at the bottom of the page. After that, extract
the content and move into the extracted folder. As an example, for SoCo
0.11.1 and on a Unix type system, this can be done with the following commands:
wget https://pypi.python.org/packages/source/s/soco/soco-0.11.1.tar.gz#md5=73187104385f04d18ce3e56853be1e0c tar zxvf soco-0.11.1.tar.gz cd soco-0.11.1/
Have a look inside the
requirements.txt file. You will need to install the
dependencies listed in that file yourself. See the documentation for the
individual dependencies for installation instructions.
After the requirements are in place, the package can be install with the command:
python setup.py install
After installation check
After installation, open a Python interpreter and check that :mod:`soco` can be imported and that your Sonos® players can be discovered:
>>> import soco >>> soco.discover() set([SoCo("192.168.0.16"), SoCo("192.168.0.17"), SoCo("192.168.0.10")])
SoCo allows you to control your Sonos sound system from a Python program. For a quick start have a look at the example applications that come with the library.
For discovering the Sonos devices in your network, use :meth:`soco.discover`.
>>> import soco >>> speakers = soco.discover()
You can use those SoCo instances to inspect and interact with your speakers.
>>> speaker = speakers.pop() >>> speaker.player_name 'Living Room' >>> speaker.ip_address u'192.168.0.129' >>> speaker.volume 10 >>> speaker.volume = 15 >>> speaker.play()
See for :class:`soco.SoCo` for all methods that are available for a speaker.