Installing Sonos Plugin 2.0 (development/pre-release) for Azure TTS access

How are you getting the plugin to play those files? I’m currently using mp3 files uploaded to Apple Music, but there’s quite a bit of delay.

If you can get the files to /etc/cmh-ludl/ on the Vera, you should be able to play/PlayURI http://vera-ip/port_3480/filename.mp3
I use WinSCP to get the files into the Vera.

1 Like

The plugin puts the files in /www/sonos on the Vera, and serves them with the generic URL http://vera-local-ip/sonos/...etc...

On openLuup, the port 3480 server cannot serve the sound files for TTS, so a separate web server must be used. The directory and URL are thus at the configuration discretion of the user.

1 Like

im using this:

luup.call_action("urn:micasaverde-com:serviceId:Sonos1", "PlayURI",{URIToPlay="x-file-cifs:etc/cmh-ludl/DoorChime.mp3/"}, Volume=50},726)

Im not hearing the file play

That’s an incorrect URL. CIFS is for Windows file sharing, not supported by Vera.

http://vera-local-ip/port_3480/DoorChime.mp3 if it’s installed in /etc/cmh-ludl/

luup.call_action("urn:micasaverde-com:serviceId:Sonos1", "PlayURI",{URIToPlay="http://vera-local-ip/port_3480/DoorChime.mp3"}, Volume=50},726)

Like this?

Yes, you need to put in the actual IP address of your Vera, but that’s the correct form.

1 Like

So the result im getting from the test Lua code in AltUI is as follows:
luup.call_action("urn:micasaverde-com:serviceId:Sonos1", "PlayURI",{URIToPlay="http://192.168.1.64/port_3480/DoorChime.mp3"}, Volume=50},726)

"[string "ALTUI - LuaRunHandler"]:1: ')' expected near '='"

Try this. You are missing something…

luup.call_action("urn:micasaverde-com:serviceId:Sonos1", "PlayURI",{URIToPlay="http://vera-local-ip/port_3480/DoorChime.mp3"}, {Volume=50},726)

edit: sorry corrected for auto oriented quotes.

Yes thank you I figured it out, it was missing some curly brackets. Works like this now:

luup.call_action("urn:micasaverde-com:serviceId:Sonos1", "PlayURI",{URIToPlay="http://192.168.1.64/port_3480/DoorChime.mp3", Volume=50},726)

Just for fun, I tested it out and it worked perfectly in that it played the stated static sentence(s) with no issues. That said, unlike when playing the Azure voice, the Sonos did not return to its original state from a volume perspective. After playing, it went to 0 and I had to turn it up to continue hearing the TV. Any idea why that would happen. If not, no worries, still working fine with your plugin running Azure but was just curious.

The PlayURI action does not save and restore state. That’s not its job.

There are only two actions that attempt to save and restore state: Say and Alert. If you just want to play an audio file and you don’t need the plugin to perform TTS conversion, Alert is the correct action:

luup.call_action("urn:micasaverde-com:serviceId:Sonos1", "Alert",
                 {URI="...", Duration=15},
                 678)

The URI must start with http:// or https:// or be one of the accepted forms on the “Help” tab of a Sonos zone player device. The Duration must be specified for save/restore to work (save/restore will not happen if it is omitted).

Other optional parameters:

  • GroupDevices – a comma separated list of other device numbers or device names on which the alert should be also played;
  • GroupZones – “ALL” to play on all zones, “CURRENT” to play on all zones in the target player’s current group, or blank to play only on the target player.
  • Volume – you know;
  • SameVolumeForAll – 0 or 1 to set the volume (if possible) the same for all devices;

Thanks for the very thorough explanation/education on this one. Very much appreciated.

I continue to be dead in the water in trying to control my Sonos system with some very basic scenes using the Advanced Scene Editor. I posted about this in the v1.5 thread last night.

@LibraSun suggested I install 2.0. My hesitation was the guidance from @rigpapa to install this version only if I needed TTS, which I don’t. But in reading the entire thread, it looks like a lot of development effort went into this version, so I gave it a try, with a totally clean install. That all worked fine - I have all my Sonos devices (although strangely no logos/icons this time), and they are controllable through the UI7 interface without any issue. However, I still cannot re-create my basic scenes which simply group some of my components (this works), set individual zone volumes (this doesn’t) and then play one of my “Favorites” (this works). This all worked fine under the old v1.4 plugin (and continues to work fine in my other home which is still running the 1.4 plugin), so I’m confused. I can only assume I’m doing something wrong in building my scene (possibly omitting additional parameters that I didn’t previously need?). The SetVolume command is just not doing anything, while all the other commands (LeaveGroup, JoinGroup and SetGroupVolume do work). Here’s an example of one of my simple scenes that used to work…

Perhaps the issue is with the Advanced Scene Editor, and I need to just write some Lua code instead? Does anyone have an example of the code that results when you set the volume of particular zone through the interface (or can tell me how I can find that code myself)? Any and all guidance would be appreciated - I just want my three simple scenes back that set some volumes and turn on my favorite Sonos music :expressionless:

I’d also like to again thank @rigpapa for all the work put into this.

1 Like

You discovered that my recommendation of switching up to ver. 2.0 of the Sonos plug-in was indeed founded on the many “little things” that we watched @rigpapa do to get that working, at which point the general consensus was “Yay, better!”

Now, I’m back to ask, why use Scenes instead of Reactor? It almost hurts my heart to see anyone using Scenes any more on Vera, considering how much “better” Reactor has been for all of my work flows. Literally, the only Scene I left intact is the one that resets Reactor after a user-induced SNAFU!

I don’t mean to chase you down unnecessary rabbit holes. Certainly, it sounds like you should be able to lick this problem without pulling out any big guns… you’ve checked the Sonos device’s assigned IP (static recommended); you’ve compared everything with your known-working environment; you’ve updated the controlling plug-in and rebuilt its parent device from scratch.

I assume (correctly?) that you’ve also hard-reset (CTRL-F5) your Vera UI and given it all time to “settle” into a known state, and still come up empty for the task at hand.

Short of @rigpapa swooping in on his gleaming stallion to save the day – which he will … stand by – I’d leave you with the only next step I know to try and that is, “Install Reactor and see if you can get it to do all the things.” :wink:

  • Libra

Thanks @LibraSun. I’m game for anything, so I’ll give Reactor a try - have never used it before. I’ve used a lot of Plug-ins and written my share of Lua code in my time, but I do prefer to keep things simple, which is why I’m hoping I can eventually get these simple Vera scenes to run, but let’s see if Reactor can get me back to functional for now.

1 Like

I love (among 1000 other things) how Reactor lets you use “Run Lua” as one of its dozen-or-so Activities, so all your code snippets will have a cozy home alongside “Device Action”, “Delay” and “Set Variable”, etc.

Once you experience the “Click to re-order things” and instant one-click “Save” mechanism in Reactor, you will want a LOT of your time back from Scene creation and debugging, I can assure you that. :wink:

I never directly answered your question, sorry, since my home’s SONOS setup doesn’t have Zones.

But I can tell you that the Volume variable on my Sonos child device is set by the service urn:upnp-org:serviceId:RenderingControl / Volume

Icons take hard refreshes when first set up. It may even require an additional Luup reload.

Your scenes are passing empty data for some fields, and I can make that OK. Update to the latest dev fix: repeat steps 4-10 of the install only; then skip to step 14 (hard refresh).

What’s up with joining the “Living Room” player to itself?

By the way, when something doesn’t work as expected, the first place you should head is the LuaUPnP log. There can often be useful messages there.

1 Like

OK, progress, and many thanks to @LibraSun and @rigpapa.

So, first, as for joining the Living Room with itself, that was just a leftover command from when I was troubleshooting (I realize it wasn’t logical, but I was grasping at straws at that point).

Still no icons after several Luup reloads and hard refreshes. But this is not a concern for me - everything is working as it should without icons. I’ll go ahead an install the latest build as you suggest.

Here’s what I found out by installing and re-building scenes (as activities) in Reactor (and forgive me if I’m stating the obvious to those of you more experienced with this)…

  • Apparently I needed to include a parameter in the “Channel” field when using SetVolume. While that didn’t seem to be necessary in v1.4, it apparently is now. That solved the SetVolume problem immediately.
  • Apparently Sonos doesn’t like receiving a stream of commands all at once - in Reactor I had to insert 1-second delays between each command for Sonos to successfully execute all of them.
  • When I re-build the same scene in Vera’s scene builder and execute, even a 1-second delay between commands isn’t sufficient - several get skipped/missed.

That said, it seems I’ve essentially solved my problem with your help - thanks again.

I have one final question to which I’ve struggled to find an answer…how can I use Reactor to simply fire off it’s activitries? I realize it’s intended to be used for conditional logic, but given the fickleness of Vera’s native functionality (and the clunky scene editor), I’d prefer to keep using Reactor. I just can’t figure out how to have a list of activities in a Reactor Sensor manually triggered (which I would do via a Scene). I’m probably missing something obvious.

1 Like