Sonos plugin

Hi,

I have not tried this myself as I do not have Pandora. The SetFileToPlay should be able to handle Pandora or any other streaming service (as well as radio).

I need to spend some time figuring out the syntax though.

/anker

HI

Sonos supports few kinds of protocols:
x-file-cifs:::*,
file::audio/mpegurl:,
x-rincon:::,
x-rincon-mp3radio:
::,
x-rincon-playlist:::,
x-rincon-queue:
::,
x-rincon-stream:::*

where x-file-cifs: - is applied in SetFileToPlay.
You can’t use SetFileToPlay to play Pandora until you don’t change I_Sonos1.xml and S_Sonos1.xml.
I am not sure but I suppose you should use protocol “x-rincon-stream:::*”
I know nothing how is Pandora URI like.

Example (an old revision of Sonos files, because I use it ):
I_Sonos1.xml:


urn:micasaverde-com:serviceId:Sonos1
PlayPandora

UPnP_request(luup.devices[lul_device].ip, ipPort, UPNP_AVTRANSPORT_URL, “SetAVTransportURI”, UPNP_AVTRANSPORT_SID, {InstanceID=‘0’, CurrentURI=“x-rincon-stream:” … lul_settings.PandoraURI, CurrentURIMetaData = “”})

S_Sonos1.xml:


PlayPandora


PandoraURI
in
string


Pera Verde

So, if that works it sounds like the [tt]x-file-cifs:[/tt] protocol/handler prefix should e made conditional in SetFileToPlay, and only added when there’s not already a protocol/handler in the string.

Then the one method could handle all the types of things, now and in the future. I’ve also gotta believe there is a true UPnP spec version of this call, something that tells the Media Streamer to play something.

Hi guys,

I will (hopefully I will have the time) during easter check up on this. I will be able to check what protocols and syntax are used for the various types - Audio, Radio, WIMP (streaming service like Pandora), Queues and Playlists and then eventually document this at the plugin site.

/anker

Then the one method could handle all the types of things, now and in the future. I've also gotta believe there is a true UPnP spec version of this call, something that tells the Media Streamer to play something.

The corresponding [tt]UPnP[/tt] action is [tt]SetAVTransportURI[/tt] (as used by [tt]PlayPandora[/tt]). Why reinvent the wheel and not use [tt]SetAVTransportURI[/tt] instead of [tt]SetFileToPlay[/tt]?

Excerpt from the SDCP for the [tt]AVTransport:3[/tt] Service:

A.5 Application to Vendor-specific Streaming A.5.1 AVTransportURI Definition A AVTransportURI for a vendor-specific protocol is unspecified. The only restrictions are that it MUST follow the rules for specifying legal URIs (see http://www.ietf.org/rfc/rfc2396.txt).

[quote=“Ap15e, post:125, topic:169644”]Why reinvent the wheel and not use [tt]SetAVTransportURI[/tt] instead of [tt]SetFileToPlay[/tt]?

Excerpt from the SDCP for the [tt]AVTransport:3[/tt] Service:

A.5 Application to Vendor-specific Streaming A.5.1 AVTransportURI Definition A AVTransportURI for a vendor-specific protocol is unspecified. The only restrictions are that it MUST follow the rules for specifying legal URIs (see http://www.ietf.org/rfc/rfc2396.txt).
[/quote]

Exactly, the only caveat is that we’d need to include the relevant S_xxxx.xml files for the standard/core UPnP AV functions, like [tt]AVTransport:3[/tt], so they can be tied into JSON UI’s correctly (UI5 does some validations now on this stuff)

In the meantime, the existing “play” mechanism can be made to “see” the protocol prefix on the incoming calls and now prepend the fixed prefix… so that compat is maintained.

Just linking to [tt]http://forum.micasaverde.com/index.php/topic,10165.0.html[/tt].

I upgraded to 1.5.346, and noticed that a new Sonos revision (changeset #15) is available.

Is it fully compatible with my current UI5 release ? Or should I use rev 14 instead ?

@vascodp,
Rev 14 or 15 should be fine. The only change in rev15 was an addition of an initialization parameter for @Ap15e, since he was using the library with his Squeezebox and it needed a different [tt]Content-Type[/tt] in it’s requests.

It wasn’t going to add any functionality to the Sonos Plugin, so wasn’t worth formalizing a release for. Figured it would just end up in the next-logical train that @anker releases.

I’m thinking about buying one of these (zoneplayer 90), is this plugin still supported? Obviously I can install it manually, but I don’t see it available on the apps page so I wanted to ask before I investing into this.

Thanks,

OK, got the Sonos CONNECT, plugin works great, I do have a question; how to I specify the SET FILE TO PLAY parameter? Am I pointed to a file on the network? any advice?

<u:SetFileToPlayResponse xmlns:u=“urn:schemas-micasaverde-com:service:Sonos1:1”>
OK
</u:SetFileToPlayResponse>

I have this plug in running on a Connect:AMP and a Play 5. I do not use Luu code I simply use the Scenes and the Advance section under that.

For the set file to play parameter , I use the following details of my NAS which I check is visible via Looking up music by Folders - //192.168.1.10/media/Music/Mp3s/Changes.mp3

If anyone can help me in return to set up a Scene via the UI that simply plays a file on my Sonos when a motion or door sensor is tripped, I would really appreciate it.

It looked so straight forward to do, i set a trigger (sensor tripped), then the schedule and finally i choose the music file (& play command) under Advanced - but all it does is play the piece of music I selected, it does not seem to wait for the trigger to occur first?

@parkerc,
When defining a Scene, the values for the Trigger and Schedule are “OR” not “AND”. So if you put in a trigger for the Sensor Tripped event on your Motion sensor and you list a Schedule, then the “Action” will occur when EITHER the Trigger event occurs (Sensor Tripped) OR the Schedule event occurs.

Typically, if you want it to occur when a Trigger occurs (Sensor Tripped) “AND” only during certain times of the day, then you need a snippet of Lua.

You still define the Trigger in the same manner, but you add a snippet of Lua that “prevents” the trigger from firing if a certain Time-range occurs. This latter stuff looks like:

http://wiki.micasaverde.com/index.php/Luup_Scenes_Events#Access_the_current_time

When that code returns false, then the ACTION will not be run. If it returns true then the ACTION will be run.

@parkerc,
Do you mind posting a screenshot of that UI to better illustrate it? I actually don’t have a Sonos, so I’d like a more working/tested example that could be pushed to the Wiki also, since it’s likely a common question.

[quote=“parkerc, post:132, topic:169644”]I have this plug in running on a Connect:AMP and a Play 5. I do not use Luu code I simply use the Scenes and the Advance section under that.

For the set file to play parameter , I use the following details of my NAS which I check is visible via Looking up music by Folders - //192.168.1.10/media/Music/Mp3s/Changes.mp3[/quote]

@guessed , sure will do, I’m on the iPad at the moment so can’t post screenshots :frowning:

I have a ‘Vera’ folder full of mp3s on the NAS which are also visibe by the Sonos (which i check by using the Sonos Controller to search for music by folders) - the mp3s vary from siren sounds to vocal commands "welcome home’ prett cheesy i know but fun to play with untill it gets annoying. The spped this plugin my goal is as I alluded to above.

At 11 pm every night
Arm motion and door sensors downstairs
If tripped, play mp3 and send notification To me
At 6 am every morning
Disarm motion and door sensors downstairs

I have a list of requirements for Vera, just sadly not the ability it seems to do it as intuitively via the GUI as I thought :frowning: i

Is there good posting out there on (an idiots guide to) understanding Scenes, Triggers & Schedules ? I’ve looked at the MiOS guide and the Wiki, but they do not seem to help when things get a little more complex than just an on or off command… Are Scedules and triggers only every aligned to a specific scene ?

Thanks god people like you, the moderators and this forum are here, I’ve never spent so much time on a forum for a product before but I’m learning something new everyday…

Screenshot of the Sonos Plugin in action.

  1. Create New Scene
  2. Call it ‘Play Sonos’ - or go with what ever you want :slight_smile:
  3. Go to the Advanced option/tab
  4. Select the Sonos Living Room device (or what ever you’ve called it)
  5. Click Add
  6. Then from the drop down options list created below, Choose ‘Setfiletoplay’ and enter in the full location of that file on the NAS (pus I always ensure it’s one Sonos can see too) -e.g. //192.168.1.10/media/Music/Mp3s/Changes.mp3

Now you have selected the file, you now need to tell the Sonos you want to play it

  1. Select the Sonos Living Room device again (or what ever you’ve called it)
  2. Click Add
  3. Then from the drop down option list created below, Choose ‘Play’
  4. Confirm Changes & Save

Now you should have a scene that once run, will play the track you’ve selected.

  • Interesting to note, the above will bypass the Sonos queue process and will just play the selected track only/
  • if you know the length of the track being played you can set a delay to occur e.g 3.45mins and set another file to play - that seems to work well.
  • The above avoids any use any coding, as I’m still learning so i hope the above helps

Screenshot below

@guessed - having this on the wiki would be a huge help, a picture tells a thousand words as they say :slight_smile:

[quote=“parkerc, post:135, topic:169644”].
At 11 pm every night
Arm motion and door sensors downstairs
If tripped, play mp3 and send notification To me
At 6 am every morning
Disarm motion and door sensors downstairs[/quote]
That’s two different Scenes, both with time based event triggers.

The first has a time (scheduled) trigger for 11pm, with an action of Playing the Tune on the Sonos, and a Notification associated. It needs a liitle bit of Lua to detect the Sensor Tripped state and, if set, it’ll return false to stop the scene from continuing.

The second is similar, but simpler since its unconditional. You just list the set of actions for the time trigger of 6am.

Is there good posting out there on (an idiots guide to) understanding Scenes, Triggers & Schedules ? I've looked at the MiOS guide and the Wiki, but they do not seem to help when things get a little more complex than just an on or off command.. Are Scedules and triggers only every aligned to a specific scene ?
Not that I've seen. There are fragments of doc here and there but nothing really cohesive.

So playing a file bypasses, the queue, but what does it do once the file is done being played?

If i’m playing Pandora for example, will it resume the song, or start over?

Can you specify a Radio station to play with this command? I have a couple in favorites that I would love to specify directly.

Thank you,

The setfiletoplay uses the seturi… Fnction of the sonos upnp api, thus meaning that the queue is not touched. A sosos function for returning to previous has not been implemented though…

Playing radio stations and other streaming sources has not been implemented. Could fairly easy be, I will implement this as the next implementation.

Regards,

ankere

Thank you very much! This is all i’m waiting for :slight_smile: