SONOS: Controlling the LED’s as you want, when you want :-)

Martin 06/02/2018

During night hours, it could be great just to say: “When the sun goes down, turn off the LED’s on my Sonos devices”, and when the sun rises, turn them on again 🙂

From the Sonos APP, you can do it manually, but thats not we want!

Luckily I found this scripts from Simon Dettling (https://msitproblog.com/2016/01/04/hacking-sonos-using-windows-powershell/), where he made a Sonos Controller from Powershell. I just wanted a one-command-file and not a menu option for controlling music aso. but just for saying “LED OUT” or “LED-ON”.

So I used wireshark, and turned the LED on and on from my Sonos APP, and I found this:

<s:Envelope xmlns:s=”http://schemas.xmlsoap.org/soap/envelope/” s:encodingStyle=”http://schemas.xmlsoap.org/soap/encoding/”><s:Body><u:SetLEDState xmlns:u=”urn:schemas-upnp-org:service:DeviceProperties:1″><DesiredLEDState>Off</DesiredLEDState></u:SetLEDState></s:Body></s:Envelope>

So I took the script, and modified all the parts except the SOAP-creating-sending process, and it gave me this:

 

So just alter the IP in the scripts below, make sure your Sonos MAC are locked in DHCP server so they always get the same IP.

Add it to a scheduled task in your Home Automation Controller or just windows, and you are good to go 🙂

I’m obviously not a programmer, as this could be remade with just one script file and use UPNP to find the SONOS devices without static IP, and then just, by it’s name, tell it to be controlled.

You can also download them here:

SONOS-LED-CONTROL.ZIP

About the Author

Leave a Reply