SoCo

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)
device.add_to_queue(album)

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

Commandline example

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


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

$ socos play 192.168.0.129

Discuss

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