Sonos

:pensive:, I guess I'll resume working on my driver then. It supports TTS somewhat at least but doesn't instantly report updates made from the app (and it makes use of my RPi that was feeling a bit neglected these days). I'll probably use a combination of both drivers till you guys add all the functionality needed to make it a complete driver. Still looking forward to this release though.

1 Like

@mike.maxwell
So if I wanted to play a single mp3 on a webserver, can I use the following command?

speaker.playTrack(uri, duration, volume)

I want to use this for announcements in the home and already have the mp3s hosted on a lan Web server, just waiting for this integration.

Andy

Iā€™ve just fallen at the first hurdle.
Put in command npm install --production on my RPi and got a load of error messages.

pi@raspberrypi:~ $ npm install --production
npm ERR! install Couldnā€™t read dependencies
npm ERR! package.json ENOENT, open ā€˜/home/pi/package.jsonā€™
npm ERR! package.json This is most likely not a problem with npm itself.
npm ERR! package.json npm canā€™t find a package.json file in your current directory.

npm ERR! System Linux 4.9.35-v7+
npm ERR! command ā€œ/usr/bin/nodejsā€ ā€œ/usr/bin/npmā€ ā€œinstallā€ ā€œā€“productionā€
npm ERR! cwd /home/pi
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.21
npm ERR! path /home/pi/package.json
npm ERR! code ENOPACKAGEJSON
npm ERR! errno 34
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/pi/npm-debug.log
npm ERR! not ok code 0

Tried to find file package.json and it doesnā€™t exist.

The play track method only accepts one parameter uri, but yes this shoud work.
The easiest way to figure out the uri is to copy it from the trackUri item in the state variable after playing something from the sonos app...
After seeing the uri prefix that sonos uses, it's straightforward to then build custom uris

@mike.maxwell
Thanks Mike
I did think that the standard http://server/file.mp3 would work as the uri so Iā€™m grateful for the info.
Would this be the preferred method or is there an alternative?

Andy

I would attempt to help but my linux skills are next to none and I would probably cause you more problems.

Do you have node installed? I know itā€™s required for this api to work. I already had this installed from previous setups on my Pi from a while back. Unfortunately I donā€™t remember the right way setup node.

That will not work without a sonos style prefix (already tried it with a few radio urls),
Radio prefix: x-rincon-mp3radio://
Another: aac://
You'll see shortly

1 Like

Any luck @bobbles?

Sorry I didnā€™t respond.
Not yet. Googled how to install node.js and have done that.
Watching football so gave up. (Or is that soccer. Depends where your from. :smile:)
Will perhaps have another look tomorrow.

Sonos is now available in latest update .709

3 Likes

Yipeeeeeeeeeeeeee!

Downloading now

1 Like

@mike.maxwell
Mike did you change something with the sonos implimentation?
Http call to mp3 DOES work

Found by accident as an already configured app triggered.

Andy

1 Like

no, turns out it works just fine for mp3ā€™s

1 Like

Sure Doesā€¦
Iā€™ll post a little app for it in about 10 mins :slight_smile:

Andy

1 Like

App posted here...

Andy

2 Likes

@mike.maxwell, in ST I used the below code to pull a list of recently played uriā€™s that could then be saved as playlist presets. It doesnā€™t seem to work with the new sonos device drivers. Is this possible with your integration? Specifically line 3 below. Iā€™ve changed ā€œtrackDataā€ to ā€œenqueuedUriā€ but it doesnā€™t return anything. Ohā€¦and ā€œsonosā€ is the musicplayer device input variable.

def stationSelections(){	//retrieves recently played stations from sonos speaker and presents as options when choosing station in VPLs
    def newOptions = state.savedPList.findAll()//{it.selected==true}	//ensures previously selected stations are included in the new list
    def states = sonos.statesSince("trackData", new Date(0), [max:30]) //??gets all previously played tracks from sonos speaker
    states?.each{	//for each track in the fresh list
    	def stationData = it.jsonValue
        if(!newOptions.find{fav->fav.station==stationData.station}){ //checks whether previously selected tracks(newOptions) exist in the new list and prevents adding second entry
   			newOptions << [uri:stationData.uri,metaData:stationData.metaData,station:stationData.station]
        }
    }
    def options = newOptions.collect{it.station?:"N/A"}.sort()
    state.savedPList = newOptions
	return options
}

the trackData json isnā€™t currently being sent to the event stream, which is why this wonā€™t work currently.

Gotcha. Please let me know if that changes so I can bring this app over.

what do we need to get SONOS to talk to the hub?

Not sure what youā€™re asking but the simple answer is ā€¦ install the Sonos App.

1 Like