Sonos plugin

The serviceId string is incorrect. ServiceId strings have :serviceId: in them, not :device:. They are sometimes different in other ways also.

“hover” your mouse over the label of a Sonos-specific variable in the Advanced Tab of the device to see what the string really should be… the bubble help for the Variable’s Label will let you know the serviceId.

[quote=“guessed, post:181, topic:169644”]The serviceId string is incorrect. ServiceId strings have :serviceId: in them, not :device:. They are sometimes different in other ways also.

“hover” your mouse over the label of a Sonos-specific variable in the Advanced Tab of the device to see what the string really should be… the bubble help for the Variable’s Label will let you know the serviceId.[/quote]

Thanks for the response and the pointer as to where I should look.

Unfortunately none of my three Sonos devices have any variables in the Advanced Tab other than Configured = 0 and Last Update = 0, and those don’t do anything when hovered over.

I did a bit of Googling and came up with what I think is the serviceid that I need: urn:micasaverde-com:serviceId:Sonos1

I modified the code (as below) and retested.

local DEVICE_NO = 27 – the Office Sonos device number
local LS_SID = “urn:micasaverde-com:serviceId:Sonos1”

local lul_arguments = {}
lul_arguments[“newSetFileToPlay”] = “//FND/Music/Doorbell/Tubular_westminster_8.mp3”
lul_resultcode, lul_resultstring, lul_job, lul_returnarguments = luup.call_action(LS_SID,“SetFileToPlay”, lul_arguments,DEVICE_NO)

local lul_arguments1 = {}
lul_resultcode, lul_resultstring, lul_job, lul_returnarguments = luup.call_action(LS_SID,“Play”, lul_arguments1,DEVICE_NO)

return true

But that doesn’t work either.

Still, a step closer perhaps… :slight_smile:

Thanks for your help.

Being a complete Noob to programming, I thought I would have ago - it claims message sent, but nothing happend.

local DEVICE_NO = “serviceId:5” – the Office Sonos device number
local LS_SID = “urn:schemas-micasaverde-com:device:avmisc:1”

local lul_arguments = {}
lul_arguments[“SetFileToPlay”] = “//192.168.1.10/media/Music/Vera/2001_Sorry.mp3
lul_resultcode, lul_resultstring, lul_job, lul_returnarguments = luup.call_action(LS_SID,“SetFileToPlay”, lul_arguments,DEVICE_NO)

local lul_arguments1 = {}
lul_resultcode, lul_resultstring, lul_job, lul_returnarguments = luup.call_action(LS_SID,“Play”, lul_arguments1,DEVICE_NO)

return true

[quote=“parkerc, post:183, topic:169644”]Being a complete Noob to programming, I thought I would have ago - it claims message sent, but nothing happend.

local DEVICE_NO = “serviceId:5” – the Office Sonos device number
local LS_SID = “urn:schemas-micasaverde-com:device:avmisc:1”

local lul_arguments = {}
lul_arguments[“SetFileToPlay”] = “//192.168.1.10/media/Music/Vera/2001_Sorry.mp3
lul_resultcode, lul_resultstring, lul_job, lul_returnarguments = luup.call_action(LS_SID,“SetFileToPlay”, lul_arguments,DEVICE_NO)

local lul_arguments1 = {}
lul_resultcode, lul_resultstring, lul_job, lul_returnarguments = luup.call_action(LS_SID,“Play”, lul_arguments1,DEVICE_NO)

return true[/quote]

Well I am new to Lua/Luup but the reason for the “Message Sent” response is just the “return true” at the end of the code. It doesn’t have anything to do with success in this case. Success would simply be sound from your Sonos of choice.

In your case, I am not sure if your device number is correct. The reference suggests that a number or string is acceptable but I am guessing that means either:

local DEVICE_NO = “5”

or

local DEVICE_NO = 5

But as a noob to Luup, I could be wrong on that…

According to this file:
http://code.mios.com/trac/mios_sonos-wireless-music-systems/browser/trunk/S_Sonos1.xml

The method is [tt]SetFileToPlay[/tt] and the parameter name is [tt]FileToPlay[/tt]. I can’t test it (since I don’t have a Sonos) but it should be something like:

[code]local DEVICE_NO = 27 – the official Sonos device number
local LS_SID = “urn:micasaverde-com:serviceId:Sonos1”
local MN_SID = “urn:micasaverde-com:serviceId:MediaNavigation1”

luup.call_action(LS_SID, “SetFileToPlay”, {FileToPlay = “//FND/Music/Doorbell/Tubular_westminster_8.mp3”}, DEVICE_NO)
luup.call_action(MN_SID, “Play”, {}, DEVICE_NO)
[/code]

Note that the serviceId for Play is different, since it uses one from the MiOS catalog of standard services.

@guessed

[quote=“guessed, post:185, topic:169644”]According to this file:
http://code.mios.com/trac/mios_sonos-wireless-music-systems/browser/trunk/S_Sonos1.xml

The method is [tt]SetFileToPlay[/tt] and the parameter name is [tt]FileToPlay[/tt]. I can’t test it (since I don’t have a Sonos) but it should be something like:

[code]local DEVICE_NO = 27 – the official Sonos device number
local LS_SID = “urn:micasaverde-com:serviceId:Sonos1”
local MN_SID = “urn:micasaverde-com:serviceId:MediaNavigation1”

luup.call_action(LS_SID, “SetFileToPlay”, {FileToPlay = “//FND/Music/Doorbell/Tubular_westminster_8.mp3”}, DEVICE_NO)
luup.call_action(MN_SID, “Play”, {}, DEVICE_NO)
[/code]

Note that the serviceId for Play is different, since it uses one from the MiOS catalog of standard services.[/quote]

That’s excellent, I have just tested that code and it works!

I never would have guessed that in a million years (no pun intended).

I have so much to learn about all of this, but I think it looks like an interesting journey.

I have never tried viewing those xml files in a browser before (but it seems such an obvious thing to try now), and they looked like a complete nightmare in Notepad++. ::slight_smile:

Now time to start playing some more.

Thanks again for your help.

[quote=“parkerc, post:164, topic:169644”]@Anker @Guessed and everyone.

In an attempt to get Vera to talk to me via my Sonos I found that I could create and add the following URL

http://translate.google.com/translate_tts?tl=en&q=kitchen+lights+off

as a new streaming Radio station and it plays really nicely.

It’s my hope that the next update to the Sonos Plugin will allow me to pick and play a radio station, but I also have the goal to see (with help) if I can put together a piece of code (that could e.g take the device or room name etc.) and dynamically creates these URLs and then plays them automatically via the Sonos.

Any thoughts?[/quote]

@parkerc
This is iteresting, and as you state that sonos is able touse it as a radiostation, then some parameter controlled code will be able to make vera initiate this on the sonos…

Will be able to test this when I get around to enable the SetRadiostationToPlay (or what it should be called) function…

Thanks Anker.

Thinking about speech and TTS via a set of preset radio stations a bit more , while good, it would be basically the same as using a ‘setfiletoplay’ option but just pointing to e.g a station name etc.

So to stay ‘offline’ you can basically use one of the TTS services to create some stactic spoken MP3s for you to host locally - the real gold is in the potential of streaming a dynamically created URL.

E.g. For thermostatic devices

http://translate.google.com/translate_tts?tl=en&q=the+[DeviceName]+in+[DeviceLocation]+is+[Value]+Degrees

Or click virtual switch for a status report on all devices, which send a series of URLs to The Sonos.

It’s a dream that I’m sure many of us share :wink:

As a back up to this, I am working on turning my Raspberry Pi into a speech box that uses the line in on the Sonos, but to be effective this plug in would need to be able to change sources etc. ;(

hi,

I just uploaded a version 18 in the trunk: http://code.mios.com/trac/mios_sonos-wireless-music-systems/browser/trunk?order=name#

New function is a SetURIToPlay that allows us to use all protocols used by Sonos.

– x-file-cifs:
– file:
– x-rincon:
– x-rincon-mp3radio:
– x-rincon-playlist:
– x-rincon-queue:
– x-rincon-stream:

– example is DR Jazz Radio where SetURIToPlay will be “x-rincon-mp3radio://live-icy.gss.dr.dk:8000/Channel22_HQ.mp3”

There seems to be some issues with the MetaData, but the above radio station streams well.

the TTS mentioned earlier in this thread should now be a posibility, but I do not know what protocol this should use.

As always I am on UI4 only.

Pls check and get me some feedback if it works for you…

N.B… the SetFileToPlay has not been removed.

Regards,

Anker

Hi Anker

I’ve just uploaded the new files and now cannot see “setfiletoplay” or “seturltoplay”?

I’m using the latest version of UI5 ?

It looks like the urn:micasverde-com:serviceId:Sonos1 is now not listed at all in the drop down list for a scene?

Reverting to v.14 and it reappears?

@parkerc

Strange, can you see the Play, Stop, etc?

I think that guessed sorted this out last time when making this work on UI5, but guess I wasn’t clever enough to dig into what he changed…

I will check up on this after the week-end.

/anker

Hi Anker,

Yep, Play etc is there in v 18’

Those actions are under the urn:micasverde-com:serviceId:Media navigation1 section,
the whole section for serviceId:Sonos1 is the one that is missing for me?

Just a side post, I found this for an Android App, it looks like it uses the same sort of code Vera would. http://gitorious.org/andronos/andronos/commit/8e696ca5716ebee7368eee7815b790f782941ae1/diffs

Examples.

val=“x-rincon-mp3radio://www.dr.dk/netradio/Metafiler/asx/dr_p3_128.asx” />
val=“mms://wmscr1.dr.dk/e02ch03m?wmcontentbitrate=300000” />
val=“rtsp://wmscr1.dr.dk/e02ch03m?wmcontentbitrate=300000” />

So we wait for @guessed to fix it like last time? Has anyone tried the tts option? I’ll give it a try today. I thanks to @anker and to @guessed!

Sent from my SPH-D710 using Tapatalk 2

It’s all there for me, i upload all 4 files, not just the new ones…
I am however having trouble playing the TTS google link
I’ve tried every combo possible including:
http://192.168.0.40:3480/data_request?id=action&DeviceNum=163&serviceId=urn:micasaverde-com:serviceId:Sonos1&action=SetURIToPlay&URIToPlay=x-rincon-mp3radio//translate.google.com/translate_tts?tl=en&q=the+test+is+on+to+verify+playback

The error i’m commonly getting is “translate_tts?tl=en Station Not Found” which makes me wonder if the plugin or Vera, or Sonos is getting hung up on the “&” part of the URL…

here are the invoke options to confirm all functions available;
urn:micasaverde-com:serviceId:Sonos1
*Mute
*UnMute
*SetVolume (NewVolume)
*SetFileToPlay (FileToPlay)
*SetURIToPlay (URIToPlay)

urn:micasaverde-com:serviceId:Volume1
*Down
*Mute
*Up

urn:micasaverde-com:serviceId:MediaNavigation1
ChapterDown
ChapterUp
DiskDown
DiskUp
FastForward
*Pause
*Play
QuickSkip
Rewind
*SkipDown
*SkipUp
Slow
*Stop

urn:micasaverde-com:serviceId:HaDevice1
Reconfigure
StressTest
Remove
Poll
ToggleState
SetPollFrequency

urn:schemas-micasaverde-com:device:avmisc:1

@Big517 - what version are you on?
I’ve tried a few times now to install it but the serviceId:Sonos1 list just does not even come up.

A few thoughts on the code you used (not being a specialist at all) did you try it in “quotes” or with a www at the start or a file type at the end .mp3?

http://192.168.0.40:3480/data_request?id=action&DeviceNum=163&serviceId=urn:micasaverde-com:serviceId:Sonos1&action=SetURIToPlay&URIToPlay=“x-rincon-mp3radio//translate.google.com/translate_tts?tl=en&q=the+test+is+on+to+verify+playback”

Just a thought, I’d love to help test but can’t work out why I do not have those functions available to me…

[quote=“parkerc, post:196, topic:169644”]@Big517 - what version are you on?
I’ve tried a few times now to install it but the serviceId:Sonos1 list just does not even come up.

A few thoughts on the code you used (not being a specialist at all) did you try it in “quotes” or with a www at the start or a file type at the end .mp3?

http://192.168.0.40:3480/data_request?id=action&DeviceNum=163&serviceId=urn:micasaverde-com:serviceId:Sonos1&action=SetURIToPlay&URIToPlay=“x-rincon-mp3radio://translate.google.com/translate_tts?tl=en&q=the+test+is+on+to+verify+playback”

Just a thought, I’d love to help test but can’t work out why I do not have those functions available to me…[/quote]

You are running the latest version: 1.5.408 .
I downloaded all files in the Trunk 18 link, you may want to re-uplaod them just in case…

No luck on the quotation marks. I experimented with the working radio station link and found that they do not allow the station to play… You did however forget the “:” after mp3radio so I fixed it in the link above. Hope you have better luck.

[quote=“big517, post:195, topic:169644”]I’ve tried every combo possible including:
http://192.168.0.40:3480/data_request?id=action&DeviceNum=163&serviceId=urn:micasaverde-com:serviceId:Sonos1&action=SetURIToPlay&URIToPlay=x-rincon-mp3radio//translate.google.com/translate_tts?tl=en&q=the+test+is+on+to+verify+playback

The error i’m commonly getting is “translate_tts?tl=en Station Not Found” which makes me wonder if the plugin or Vera, or Sonos is getting hung up on the “&” part of the URL…[/quote]it’s not encoding the URI internally (right now) but you can test if that’s the issue by changing the & in the URL into & like this:

http://192.168.0.40:3480/data_request?id=action&DeviceNum=163&serviceId=urn:micasaverde-com:serviceId:Sonos1&action=SetURIToPlay&URIToPlay=x-rincon-mp3radio//translate.google.com/translate_tts?tl=en&q=the+test+is+on+to+verify+playback

[quote=“guessed, post:198, topic:169644”]The error i’m commonly getting is “translate_tts?tl=en Station Not Found” which makes me wonder if the plugin or Vera, or Sonos is getting hung up on the “&” part of the URL…[/quote]it’s not encoding the URI internally (right now) but you can test if that’s the issue by changing the & in the URL into & like this:

http://192.168.0.40:3480/data_request?id=action&DeviceNum=163&serviceId=urn:micasaverde-com:serviceId:Sonos1&action=SetURIToPlay&URIToPlay=x-rincon-mp3radio//translate.google.com/translate_tts?tl=en&q=the+test+is+on+to+verify+playback
[/quote]

Same error, I tried x-rincon-stream:, and x-rincon-mp3radio: with no luck… Parkerec said he was able to save this as a Station, then play. How would we specify a station that we have saved in our favorites?

Actually, given that it’s coming in on a URL it may need to be double-encoded. It’ll get decoded once by Vera, then we still need to pass an encoded value in the XML to the Sonos.

Unfortunately I don’t have a Sonos to test this against.

@anker: it looks like the IP is hardcoded in the UPnP_subscribe call also, probably not an impact right now though. You may also want to move some of the startup stuff to a call_delay block, as it’ll make startup faster.

Check also your serviceIds for the state variables you’re setting. These should likely be stored against a Sonos specific serviceId (… With “…:serviceId:…” in its name)