| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
SoCo (Sonos Controller) is a Python project that allows you to programmatically control Sonos speakers. It was originally created at Music Hack Day Sydney by Rahim Sonawalla and is now developed by a team of people at its GitHub repository
For more background on the project, please see Rahim's blog post.
Visit the SoCo documentation for a more detailed overview of all the functionailty.
SoCo requires Python 2.7, or 3.3 or newer.
Use pip:
pip install soco
SoCo depends on the Requests HTTP library. If you use pip to install Soco, Requests will be installed automatically for you. If not, you can use:
pip install requests
You can interact with a Sonos Zone Player through a SoCo object. If you know the IP address of a Zone Player, you can create a SoCo object directly:
>>> from soco import SoCo
>>> my_zone = SoCo('192.168.1.101')
>>> my_zone.player_name
Kitchen
>>> my_zone.status_light = True
>>> my_zone.volume = 6But perhaps the easiest way is to use the module-level discover function. This will find all the Zone Players on your network, and return a python set containing them:
>>> import soco
>>> for zone in soco.discover():
... print zone.player_name
Living Room
KitchenIf you prefer a list to a set:
>>> zone_list = list(soco.discover())
>>> zone_list
[SoCo("192.168.1.101"), SoCo("192.168.1.102")]
>>> zone_list[0].mute = TrueOf course, you can also play music!
#!/usr/bin/env python
from soco import SoCo
if __name__ == '__main__':
sonos = SoCo('192.168.1.102') # Pass in the IP of your Sonos speaker
# You could use the discover function instead, if you don't know the IP
# Pass in a URI to a media file to have it streamed through the Sonos
# speaker
sonos.play_uri(
'http://ia801402.us.archive.org/20/items/TenD2005-07-16.flac16/TenD2005-07-16t10Wonderboy.mp3')
track = sonos.get_current_track_info()
print track['title']
sonos.pause()
# Play a stopped or paused track
sonos.play()If you need support for SoCo, feel free to post your question either on our Google Group or on the #soco IRC channel on freenode.
To show off what can be made with SoCo, a simple web application is included in the examples folder.
SoCo supports the following controls amongst others:
SoCo also supports lower level access from Python to all Sonos services (eg Alarms)
Socos is a command line tool for controlling Sonos devices. It is developed in conjunction with Soco, but in a separate repository.
More of a Ruby fan? Not a problem, Sam Soffes is building out an awesome Ruby gem.
Looking for a GUI that’s more than just a sample project? Joel Björkman is building a Sonos Controller GUI–great for folks on Linux where there isn’t an official Sonos Controller application! Find, fork, and contribute to it here: https://github.com/labero/SoCo-Tk.
There is a Soco group over at Google Groups. Feel free to drop by for support, ideas or casual conversation related to SoCo.
SoCo is released under the MIT license.
| Back | FazBrowse Home | New Git URL |