Hacking SONOS using Windows PowerShell

This blog post is a little different from my others. I spent the Christmas days this year to be a bit creative and managed to control my SONOS Environment via Windows PowerShell.

First things first. What I am writing here is probably not supported by SONOS and is currently a preview which is not complete yet or extensively tested. So everything you do is at your own risk. I didn’t break anything while doing my tests, though.

Before I post the preview script, I want to give some facts about how the script works.

SONOS API Documentation

I actually started by looking for the SONOS API Documentation. The Search was quite short because there is actually none API Documentation.

So, what now?

The magic solution here is called: Wireshark

After starting the tool, you can limit the output to the Destination IP of your SONOS Component, connected to Ethernet. To do that, you can use the following filter: ip.dst_host == IP_ADDRESS

In my case I’m talking to a SONOS Playbar. Now you can trigger a Command the official SONOS Controller App. You should see an HTTP/XML POST request to your Destination IP, that looks like the following:

Here you can see, that the HTTP Request has a SOAP Action. If you expand the “eXtensible Markup Language” node at the end, you can view the Envelope that has the actual instruction. In this case I triggered a simple “Play” Action.

The PowerShell Script

With this knowledge, I started writing a PowerShell Script that sends an identical SOAP Action to the Playbar. To my surprise, that actually worked on the first try.

The Preview Script currently has the following 11 actions:

  • Play
  • Pause
  • Previous Track
  • Next Track
  • Rewind Track
  • Mute
  • Unmute
  • Repeat All
  • Repeat One
  • Repeat Off
  • Set Volume

The Demo Interface, which triggers the above actions, is console based and pretty simple:

SONOS_Part3

Before you start the script, make sure you open it in ISE or Notepad and change the IP Address.

SONOS_Part4

The Preview script can be downloaded at TechNet Gallery.

So that’s it for today. If you have any questions / comments / improvements, tag me on twitter or below in the Comment Section.

Hacking SONOS using Windows PowerShell
4 (80%) 1 vote

8 Comments

  1. Mirko 5. January 2016
    • mm Simon Dettling 5. January 2016
  2. Jeff Hicks 5. January 2016
    • mm Simon Dettling 5. January 2016
  3. Jeff Hicks 5. January 2016
    • mm Simon Dettling 6. January 2016
  4. buy quality jewelry 1. April 2016
  5. Martin Lindemann Frederiksen 6. February 2018

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.