A Server application & an associated Android app to stream Saavn music to Sonos speakers on your home network.
- Checkout this repo
git clone https://github.com/brijs/Sonos-Controller-Saavn.git
-
Update the service configuration
server/config.py
- Update
SERVER_USER_NAME
andSERVER_PASSWORD
to the desired values. - Update
SAAVN_API_ENCRYPTION_KEY
to the correct value (secret string). Contact project owner. - Update Sonos IP addresses to your local home network IP addresses. Two speakers are supported currently.
SONOS_SPK1_IP
andSONOS_SPK2_IP
. - Don't modify other items in config.py
- Update
-
To run the application server in a Virtualbox VM:
- In the project directory, simply run
vagrant up --provider=virtualbox
. (You need to install virtualbox & vagrant for your host OS prior to this) - The server should be accessible at https://localhost:5000. You should get a welcome message.
- In the project directory, simply run
-
To run the application in AWS:
- Update Vagrantfile with your AWS credentials (access key, secret key, keypair name, private key file)
- Run
vagrant up --provider=aws
- Note that, sonos related API calls will not work (only saavn calls will work) since this app server needs to be in the same home network as the sonos speakers. Alternatively, VPN may be set up to make it work from AWS.
-
To run the application server locally, there are a few additional steps:
- Generate a self-signed SSL certificate in
/home/vagrant/certs/
. An example command:
openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 -keyout /home/vagrant/certs/sonos.key -out /home/vagrant/certs/sonos.cert
- Install python dependencies for the project (Using virtualenv is recommended):
pip install -r server/requirements.txt
- Run server
python server/run.py
- Generate a self-signed SSL certificate in
- saavn/songs?q=
searchTerm
: returns a JSON list of matched songs. - saavn/songs: returns a JSON list of weekly top 15 songs
- sonos/player?id=
sonosId
&action=actionId
sonosId
is eitherliving
ormasterbed
actionId
can be:status
: get PLAY/PAUSE status, volume, currentTrack infoplay
pause
next
add_uri
: add to playlist, the media specified byuri
in the query paramsplay_uri
: add & play the media specified byuri
in the query paramsvolume
: set volume to theval
specified in the query paramsseek
: seek to theval
offset in the current track
Use this app to communicate with the server, to control Sonos in your home network.
- In the
Settings
tab, specify the IP address(Local) of the server running in your home network. Alternatively, you can operate inremote
access mode when you are outside your home network. You ll need to configure NAT on your home router / gateway, and in theSettings
tab, you will need to specify the public internet facing IP address of your home router. - On the
Saavn
tab, search for songs and hit enter. - Drag & pull down on the screen to refresh.
- Swipe left on a particular song and either add-song-to-queue, or add-and-play-immediately.
- Tap on a song(row), and view details of the song.