macchiato
macchiato copied to clipboard
Turn your Sonos speakers into a coffee shop.
Macchiato
Macchiato is a node.js application which turns your Sonos speakers into a coffe shop. It is meant for those who prefer to code with non-disturbing background noise.
Install & use
$ git clone https://github.com/michaelmcmillan/macchiato
$ node macchiato/macchiato.js 192.168.1.229
)))
(((
+-----+
| |)
`-----'
___________
`---------'
Macchiato
[*] uPnP: SetAVTransportURI
[*] uPnP: Play
[*] Macchiato: Streaming "audio/university.mp3" to speaker 192.168.1.229
Macchiato only takes one argument: The ip address of the speaker you want to use.
Under the hood
By using node's bundled http-library it is pretty easy to communicate with devices from Sonos. I started out by Wiresharking the network to reverse engineer the protocol. This was far from necessary due to blog posts like this. It turns out each speaker acts as a uPnP endpoint.
Macchiato spins up a static file server each time you run it on port 1337. The speakers then stream the audio files straight from Macchiato. This has several benefits: You can add your own audio files (rainy mood etc.) and it will still work without an internet connection.
To-do
If you want to help out please do a pull request. These are some of the things that needs twerking:
- Feature: Show percentage/seconds played of a track
- Improve the user experience
- Use an xml-lib to create the Soap-requests.
- Feature: Choose from a set of sounds.
- Feature: Scan the network for speakers/zones.
- Feature: Adjust volume from the command line.
- Bug: Repeat when file is finished.
References
- Coffitivity - An awesome app we borrow the audio from.
- node-sonos - Insight into the uPnP protocol with Sonos.
- Dissecting the Sonos Controller - Reverse engineering Sonos.