Controlling your Sonos speakers from Python and the commandline

Project maintained by SoCo Hosted on GitHub Pages — Theme by mattgraham

Welcome to SoCo

SoCo (Sonos Controller) lets you control your Sonos speakers from Python or the commandline.

Python example

When using Python, you need the soco package (see GitHub project).

# Import soco and get a SoCo instance
import soco
device = soco.discovery.any_soco()

# Get all albums from the music library that contains the word "Black"
# and add them to the queue
albums = device.music_library.get_albums(search_term='Black')
for album in albums:
	print('Added:', album.title)

# Dial up the volume (just a bit) and play
device.volume += 10

Commandline example

For the commandline interface you need the socos package (see GitHub project).

$ socos list
(1) Living room
(2) Bedroom

$ socos play


If you want to ask questions or start a discussion, you can find us on Google Groups.