Bluetooth Buttons

Control your Sonos speakers with Bluetooth Buttons

Here is the ideal solution to control your SONOS speakers using cheap Bluetooth Buttons, originally build to interact with your phone while driving.

The Idea

I’m pretty sure, you have heard of SONOS. They sell a wireless a Home Sound System based on high quality speakers. The Speakers are usually controlled by an app. Once you have chosen your song of choice interacting is also possible with buttons on the top of each speaker.

Well, rumors are telling an upcoming integration of voice recognition and assistance. This should make it easier to interact with your music system using your voice. An very useful feature which is totally necessary to compete and survive in times of fast evolving home assistants.

In my case I was looking for a simple and fast solution to interact with the speakers from any location in my house without always unlocking the phone, starting up the app and waiting its initialization. I was inspired by the hacks of amazons dash button, but I needed to find a solution for sending more than one command. So the ideal solution are Bluetooth Buttons, originally build to interact with your phone while driving. And hey, compared to voice control this is even easier, faster and much more noiseless (as long as you button is in reach).

The Hardware

Here is how my setup is working:

  • A Raspberry Pi 3 Model B is listening to the paired and connected buttons.
  • Once the paired Bluetooth button sends a command to the Pi, it’s forwarded to an HTTP based API controlling the SONOS Speakers.

I tested this with several buttons, as long as the button is delectable with any other Bluetooth device everything worked as expected. Here are three tested and used for some month:

The Script

As usual you can find the python based script on GitHub.

After following the installation instructions, all you need to adjust are variables in the header of the script.

# Modify your variable here
roomname = "Kitchen" # roomname your Sonos Speaker is located
buttonname = "Satechi Media Button" # also tested with "BT-005"
host = "localhost" # when installed on the same host use localhost
port = "5005" #default 5005
key2commandPairs = {"KEY_PLAYPAUSE":"playpause",  # edit your button:command pairs
                    "KEY_NEXTSONG":"next",
                    "KEY_PREVIOUSSONG":"previous",
                    "KEY_VOLUMEUP":"volume/+2",
                    "KEY_VOLUMEDOWN":"volume/-2"}
# -------------------------------------------------

 

Time to play some loud good music. Enjoy!