Remote-Controlling a Sonos Device Using Python

I couple of months ago I bought a Sonos Play:1, a pretty cool wireless speaker that comes with free controller apps for major platforms (Android, Windows etc.). To give the speaker access to my music collection, I hooked up a USB drive to my home router and shared the music via SMB, which works great.

Unfortunately, I don’t always have an Android device handy when I’m at my Linux computer, so I thought it would be really useful to have a simple command line application to control the speaker. Since the device can be remote-controlled via UPnP, I decided to write my own client. Thanks to the SoCo Python library (install via pip install soco), this was extremely easy to do.

Here’s the script that I came up with, tested with SoCo 0.6. I still manage the play queue using the Android app, but when I’m at my Linux computer I use the command line client to play, pause, control the volume, or skip tracks.

About these ads
This entry was posted in linux and tagged , , , . Bookmark the permalink.

2 Responses to Remote-Controlling a Sonos Device Using Python

  1. rdmilligan says:

    what distance do the speakers work at? could be interesting to send notifications from the pi to them using python scripts?

  2. Matthias says:

    Not sure what the maximum distance is, but it’s ordinary wifi so it should work as well as other wifi equipment. If you don’t connect the speaker directly via cable then you need a Sonos bridge which can also act as a repeater. As far as I know, you can have multiple bridges for longer distances, but as wifi repeaters they are rather expensive at 50 EUR. The price is the downside of this system in general, but the sound is great.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s