VoxCommando

Help and Support (Using VoxCommando) => Vera Home Automation Controller => Topic started by: lemrock on October 03, 2014, 02:14:42 AM

Title: Can VC Announcements be Forwarded to SONOS
Post by: lemrock on October 03, 2014, 02:14:42 AM
Hello again. I have been controlling my Vera 3 using my PC, iMac and various mobile devices. The announcements at home are via a constellation of SONOS and my computer speakers. Now that I have discovered VC with the Vera plugin I would love to be able to send the announcements created by VC to my SONOS networked speakers. I have done my due diligence and searched here on this forum, at Micasaverde and generally across the internet, yet nothing of interest has caught my attention. Can anyone point me in the right direction or is this a reach too far what I am considering? I'm using VC 2.103.
Title: Re: Can VC Announcements be Forwarded to SONOS
Post by: jitterjames on October 03, 2014, 08:56:09 AM
I am sure this is possible using either Vera or by directly controlling sonos from VoxCommando. Unfortunately it is difficult for me to figure it out without having a sonos.  Perhaps if there is enough interest a plugin could be made.

With enough micro-contributions I could get a basic sonos to play with.

I will add sonos to the plugin wish list. http://voxcommando.com/forum/index.php?topic=1620.msg14163#msg14163

What is the minimum hardware that I need?  I think you used to need a bridge in addition to something like a Play1 but I'm not sure if you still need the bridge.

Just a Sonos Play1 will set me back 250 clams.
Title: Re: Can VC Announcements be Forwarded to SONOS
Post by: nime5ter on October 03, 2014, 09:35:00 AM
If you're open to experimenting, it should be possible using Vera.Raw to send info from VC to your Sonos via the Sonos plugin for Vera. Another user pointed to it just yesterday on another thread here (maybe you're already using it?): http://code.mios.com/trac/mios_sonos-wireless-music-systems.

In VC, you can choose to use TTS.Speak2Wav, which saves the TTS announcement as a wav file. It seems like you should be able to send this to your Sonos speakers via Vera.

Based on the documentation provided at the above link, below is a complete guess of what the Vera.Raw string would look like.

Some trial and error will likely be involved, and perhaps seeking help over on the Vera boards.

[UPDATE: This thread involves a lot of trial and error. See later in this thread --> http://voxcommando.com/forum/index.php?topic=1778.msg15657#msg15657 onward for discussion of what actually works.]

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.0.3-->
<command id="140" name="Send your tts to Sonos" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="data_request?id=action&amp;DeviceNum=[YourSONOSDEVICENUMBER]&amp;serviceId=urn:micasaverde-com:serviceId:Sonos1&amp;action=SetURIToPlay&amp;URIToPlay=x-file-cifs://[FILE PATH TO THE WAV FILE]&#xD;&#xA;&#xD;&#xA;May need to experiment or get help at Vera for file path syntax. or syntax overall.&#xD;&#xA;">
  <action>
    <cmdType>TTS.Speak2Wav</cmdType>
    <params>
      <param>This is the TTS announcement</param>
      <param>D:\tts.wav</param>
      <param>False</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Vera.Raw</cmdType>
    <params>
      <param>data_request?id=action&amp;DeviceNum=123&amp;serviceId=urn:micasaverde-com:serviceId:Sonos1&amp;action=SetURIToPlay&amp;URIToPlay=x-file-cifs://192.168.0.100/D/tts.wav</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>Send your tts to Sonos</phrase>
</command>
Title: Re: Can VC Announcements be Forwarded to SONOS
Post by: lemrock on October 03, 2014, 11:32:01 AM
A bridge is no longer required if you have a simple audio set up. I have two Play 1's.
Title: Re: Can VC Announcements be Forwarded to SONOS
Post by: lemrock on October 03, 2014, 11:35:37 AM
@nime5ter, I do use the Sonos plugin. This weekend I will start with the code you provided and tinker some and see what I can come up with. I will report out my findings.
Title: Re: Can VC Announcements be Forwarded to SONOS
Post by: nime5ter on October 03, 2014, 11:48:27 AM
Excited to hear it. We look forward to your report.
Title: Re: Can VC Announcements be Forwarded to SONOS
Post by: jitterjames on October 03, 2014, 03:14:22 PM
A bridge is no longer required if you have a simple audio set up. I have two Play 1's.

Cool.  If you only have a Play1 can you use it through the house wifi, or do you need to plug a network cable into it?
Title: Re: Can VC Announcements be Forwarded to SONOS
Post by: lemrock on October 03, 2014, 04:14:47 PM
The Play 1 can connect through home wifi or Ethernet.
Title: Re: Can VC Announcements be Forwarded to SONOS
Post by: lemrock on October 06, 2014, 04:01:45 AM
Well, I worked a fair amount over the weekend using the code provided from nime5ter . But alas, no joy... I believe the code you provided is working. The tts.wav file is generated and I get a response from SONOS. What ever is playing stops and tts.wav is queued up but I get an Access Denied error. I took a stroll over to the SONOS forums and there are lots of Access Denied discussions and tried everything I could find. Changing file permissions, adjusting the firewall, taking down the firewall....nothing. So anyone have any additional suggestions.

By the way it turns out that SONOS has issues with .wav files, they aren't recommended. So I created an .mp3 but the same issues.
Title: Re: Can VC Announcements be Forwarded to SONOS
Post by: nime5ter on October 06, 2014, 08:20:21 AM
Bummer.

Sounds like it's either not allowed to access that file path, or somehow the path syntax being used is wrong and access is denied because the path is invalid.

Maybe try to instruct Sonos to play a file that it already knows how to play (i.e. a music file from a folder it already accesses) to make sure you're getting the path syntax correct. That is, in your VC command, try to get it to play that file.

If that works, then try copying the TTS wav to the same folder on the music server (or wherever it is) and see if it will play the wav in that location.

If that works, then either get VC to save your TTS to that location when it's being generated, or try to figure out the difference access-wise between the original path and the path that works. Maybe Sonos can only play files from paths that have already been registered with it as valid sources, or something along those lines.
Title: Re: Can VC Announcements be Forwarded to SONOS
Post by: crawfofd on October 07, 2014, 01:10:26 AM
I did get the sonos to play a wav file from vc. You need to create a file and make sure it is in your sonos library. Then just keep writing what you want outputted to that same file. I will try to work up a complete process later today and post it.
Title: Re: Can VC Announcements be Forwarded to SONOS
Post by: nime5ter on October 07, 2014, 09:36:53 AM
Thanks crawfofd. That would be really helpful.
Title: Re: Can VC Announcements be Forwarded to SONOS
Post by: lemrock on October 07, 2014, 06:13:44 PM
Quote from nime5ter
Quote
Maybe try to instruct Sonos to play a file that it already knows how to play (i.e. a music file from a folder it already accesses) to make sure you're getting the path syntax correct. That is, in your VC command, try to get it to play that file.

If that works, then try copying the TTS wav to the same folder on the music server (or wherever it is) and see if it will play the wav in that location.

If that works, then either get VC to save your TTS to that location when it's being generated, or try to figure out the difference access-wise between the original path and the path that works. Maybe Sonos can only play files from paths that have already been registered with it as valid sources, or something along those lines.

I did all of these steps and I was able to get Sonos to play both mp3 and wav files from a folder on my PC. I got the proper path from my Sonos PC controller and used that path in the command string from VC. Good news, I'm not getting the access denied error but still no playing of the file thru Sonos.  Is there a log file I can review that might help me do a trace? Obviously inching closer to a solution but I'll experiment some more.
Title: Re: Can VC Announcements be Forwarded to SONOS
Post by: lemrock on October 07, 2014, 06:36:19 PM
Oh, I see crawfold may have a solution. I'll wait for that.
Title: Re: Can VC Announcements be Forwarded to SONOS
Post by: nime5ter on October 07, 2014, 06:41:55 PM
Yes, here's hoping he has time to get to that soon.

If all else fails, you can resort to using the robotic Google Translate TTS voice until a better solution comes along, using the following URIToPLay syntax in your Vera.Raw string instead of the URIToPlay substring used above:

Code: [Select]
URIToPlay=x-rincon-mp3radio://translate.google.com/translate_tts?tl=en&q=[YOUR TTS MSG GOES HERE]
Found here: http://forum.micasaverde.com/index.php/topic,11269.msg82963.html#msg82963

(I tested the URL and it works but sounds terrible. ... And obviously, if your Internet is down, then no TTS.)
Title: Re: Can VC Announcements be Forwarded to SONOS
Post by: jitterjames on October 07, 2014, 07:06:19 PM
you can try using the en-gb translation language:
Code: [Select]
URIToPlay=x-rincon-mp3radio://translate.google.com/translate_tts?tl=en-gb&q=[YOUR TTS MSG GOES HERE]
instead of
Code: [Select]
URIToPlay=x-rincon-mp3radio://translate.google.com/translate_tts?tl=en&q=[YOUR TTS MSG GOES HERE]
Sounds slightly better
Title: Re: Can VC Announcements be Forwarded to SONOS
Post by: jitterjames on October 07, 2014, 07:08:36 PM
Quote from nime5ter
I did all of these steps and I was able to get Sonos to play both mp3 and wav files from a folder on my PC. I got the proper path from my Sonos PC controller and used that path in the command string from VC. Good news, I'm not getting the access denied error but still no playing of the file thru Sonos.  Is there a log file I can review that might help me do a trace? Obviously inching closer to a solution but I'll experiment some more.
You can enable logging in VC but I don't think it will show you anything useful in this case.
Title: Re: Can VC Announcements be Forwarded to SONOS
Post by: crawfofd on October 07, 2014, 10:19:34 PM
http://code.mios.com/trac/mios_sonos-wireless-music-systems

The above link will give some info on the vera side set up. I was not able to do the write up today, to busy. I will get to it tonight and should have it by tomarrow. Sorry for delay.
Title: Re: Can VC Announcements be Forwarded to SONOS
Post by: lemrock on October 08, 2014, 12:57:31 AM
@nime5ter

Could you tell me why I'm getting this "ERROR: Invalid service/action/device". I'm using the code you gave me a few days ago and didn't ever see this before and my Vera 3 is behaving badly. Everything reads exactly the way you gave it.
Title: Re: Can VC Announcements be Forwarded to SONOS
Post by: lemrock on October 08, 2014, 01:09:43 AM
Here is the corresponding error I get from the Vera 3 log after it receives the requests from VC.

Thanks for whatever help you can offer in my troubleshooting.
Title: Re: Can VC Announcements be Forwarded to SONOS
Post by: jitterjames on October 08, 2014, 09:00:32 AM
It's a mystery.  Maybe there is a problem with your Sonos plugin on your Vera.

I do notice that your wav file path does not include the drive letter.  That might be OK depending on how you have created your network share though.

The service id you are using appears to be correct, assuming that you have the Sonos plugin for Vera correctly installed and up to date.

Although Vera appears to be complaining about the service id, maybe you should double check the device id you are using, and the path to the wav.
Title: Re: Can VC Announcements be Forwarded to SONOS
Post by: nime5ter on October 08, 2014, 09:12:25 AM
http://code.mios.com/trac/mios_sonos-wireless-music-systems

The above link will give some info on the vera side set up. I was not able to do the write up today, to busy. I will get to it tonight and should have it by tomarrow. Sorry for delay.

The main challenge Lemrock has is getting the Vera.Raw syntax right in his VC command. Would you have time to just post the xml for one of your VC commands that is sending the TTS message?

Or did you create a scene in Vera that plays the TTS file, and then you're just calling the scene from VC?

thx
Title: Re: Can VC Announcements be Forwarded to SONOS
Post by: jitterjames on October 08, 2014, 09:18:23 AM
Quote from nime5ter
I did all of these steps and I was able to get Sonos to play both mp3 and wav files from a folder on my PC. I got the proper path from my Sonos PC controller and used that path in the command string from VC. Good news, I'm not getting the access denied error but still no playing of the file thru Sonos.  Is there a log file I can review that might help me do a trace? Obviously inching closer to a solution but I'll experiment some more.

I am confused by this, and your subsequent posts.  It sounds like you succeeded in playing a wav file.  So how did you do that?

From what I can tell, you first need to figure out how to get Vera talking to Sonos.  Then the VC part is child's play.  Maybe you need to take a second look at the Vera forum for this.
Title: Re: Can VC Announcements be Forwarded to SONOS
Post by: nime5ter on October 08, 2014, 11:27:30 AM
@Lemrock -- I don't know if this will help or not, but I found a post on the Vera form explaining that one should use "PlayURI" to play a media file. "SetURItoPlay" apparently only loads a file, but doesn't play it.

http://forum.micasaverde.com/index.php/topic,13738.msg103378.html#msg103378

In general, maybe that thread will help. Or just post your problem to that thread so that the plugin developer can help you.

If the only thing that needs changing is "PlayURI" then it would be:

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.0.3-->
<command id="140" name="Send your tts to Sonos" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="data_request?id=action&amp;DeviceNum=[YourSONOSDEVICENUMBER]&amp;serviceId=urn:micasaverde-com:serviceId:Sonos1&amp;action=PlayURI&amp;URIToPlay=x-file-cifs://[FILE PATH TO THE WAV FILE]&#xD;&#xA;&#xD;&#xA;May need to experiment or get help at Vera for file path syntax. or syntax overall.&#xD;&#xA;">
  <action>
    <cmdType>TTS.Speak2Wav</cmdType>
    <params>
      <param>This is the TTS announcement</param>
      <param>D:\tts.wav</param>
      <param>False</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Vera.Raw</cmdType>
    <params>
      <param>data_request?id=action&amp;DeviceNum=184&amp;serviceId=urn:micasaverde-com:serviceId:Sonos1&amp;action=PlayURI&amp;URIToPlay=x-file-cifs://192.168.81.191/VoxCommando/tts.wav</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>Send your tts to Sonos</phrase>
</command>

However, in your error message, the bit about device: 0 and device -1 looks odd. So maybe double-check your Sonos device ID. Or if there's more than one, try the other ...

(Really, the best place to get support for these problems would be the Vera forum.)
Title: Re: Can VC Announcements be Forwarded to SONOS
Post by: crawfofd on October 08, 2014, 02:16:13 PM
Okay here is the way I set up VC to talk to Vera to output to Sonos devices.

Refer to this Web site: http://code.mios.com/trac/mios_sonos-wireless-music-systems# (http://code.mios.com/trac/mios_sonos-wireless-music-systems#)

Pull up your Vera web site to access your Vera setup. I'm using UI5
1. Go to 'APPS' and install 'UPnP Event Proxy', No setup is required
2. Go to 'APPS' and install 'Sonos Controller' plugin. I am using version 1.1, After plugin is installed refresh browser (CTLRL-F5)
   Sonos Controller setup:
   a. Open Sonos Controller under 'My Apps'
   b. There should be a device under 'This plugin has created the following devices:'
   c. Select the device that is listed.
   d. When a popup dialog box opens select 'Settings'.
   e. Under settings select 'Discover', This will go out and retrieve the sonos devices on the network.
   f. The box to the right of the 'Discover' button will show your devices. Select the one you want to link to this controller.
   g. Press the 'Select' button next to your selection. Selected Zone: and IP: should now have the zone you selected and the IP of zone.
       Also State: should be ON.
   h. Save settings by pressing the 'X' in top right hand corner.
   
3. Go to 'AUTOMATION'
   a. Select 'New Scene'
   b. Name the Scene in top left had corner near the 'Immediate' button
   c. Select 'ADVANCED'  at the top of the page
   d. When the window opens, under 'Pick a device:' select the #?? Sonos (?? sonos device#) then select the 'Add' button to the right.
   e. Under Sonos (Please select), select 'Alert'.
       You will be given the following selections:
        URI:                     ( put path to file using =  x-file-cifs://Hostname/Directory/filename.wav )
        Volume:                ( Set volume to what ever you want )
        SameVolumeForAll   ( I did not do anything )
        Duration:               ( Duration of the wav file, start with 5 for five seconds )
        GroupDevices:        ( Put the sonos device/s to output to )
        GroupZones:          ( I did not do anything )
   f. At the top right of web page 'Confirm Changes'
   g. At the top right of web page "SAVE"

That should complete the Vera setup.  Now go to voxcommando and setup a command to call vera using TTS.Speak2Wav and Vera.Scene
 
 
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.0.3-->
<command id="1153" name="TestSonos" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>TTS.Speak2Wav</cmdType>
    <params>
      <param>This is a test of the voxcommando to sonos interface</param>
      <param>\\SAGE-MC\vera\test.wav</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Vera.Scene</cmdType>
    <params>
      <param>25</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
</command>

You will need to change the Vera.Scene to match the Scene you create in step 3a. You will also need to change the location of the wav file for the TTS.Speak2Wav.

This is the second time I've posted this. The first time it got lost when I selected post. Hopefully this time it will post. If you have any question I will be happy to help if I can. 

     
Title: Re: Can VC Announcements be Forwarded to SONOS
Post by: lemrock on October 08, 2014, 04:31:49 PM
Really, everyone...I appreciate the help. jitterjames, nime5ter and crawfold have given much more time and effort to this than I could have hoped for.

I will read thru the last few posts and try these things out tonight.

jitterjames was confused by what I said "I did all of these steps and I was able to get Sonos to play both mp3 and wav files from a folder on my PC. I got the proper path from my Sonos PC controller and used that path in the command string from VC. Good news, I'm not getting the access denied error but still no playing of the file thru Sonos."

nime5ter had suggested that I make sure I had the correct path. So all I did was put the tts.wav file in the folder that I use for my Sonos music library on my PC.  I then used the Sonos controller installed on my PC to listen to that tts.wav file. This proved that Sonos can play a wave and it also exposed the proper path. That effort solved the access denied error I was getting but still did not allow the tts.wav file to be played initiated from VC control. 
Title: Re: Can VC Announcements be Forwarded to SONOS
Post by: lemrock on October 08, 2014, 06:18:22 PM
Success!!

I used the procedure developed by crawfold. I had already completed step 1 and 2. I was already using the Sonos plugin developed for use with Vera to control the music traffic in my home. Step 3 which is the Scene development worked like a charm. Every step completed exactly as written without any issues.

AND...

I also changed the code that was provided by nime5ter and and used nime5ter's suggestion to change ""SetURItoPlay" (which only loads the file)to "PlayURI" in order to play a media file. That was why I thought the file wasn't making it's way to the Sonos. It was...it just wasn't being played.

So, there are two methods developed out of this effort that offer a way to send VC tts announcements to Vera/Sonos.

I'm done. Thank you, thank you.
Title: Re: Can VC Announcements be Forwarded to SONOS
Post by: nime5ter on October 08, 2014, 06:38:15 PM
Groovy. Many thanks to crawfofd for giving all Sonos w/ Vera users complete instructions on setting up the plugin for Vera and creating scenes for the Sonos.

In terms of the alternative method, sorry that I got the syntax wrong on my first guess. :bonk

In my defence, I did warn you it was a guess that might need to be corrected! 
Title: Re: Can VC Announcements be Forwarded to SONOS
Post by: crawfofd on October 08, 2014, 07:03:54 PM
lemrock glad you worked everything out.

nime5ter tried your way and it works pretty good and not as many steps as mine, thanks for the info.

Title: Re: Can VC Announcements be Forwarded to SONOS
Post by: lemrock on October 08, 2014, 10:17:27 PM
A Follow-up:

There is a difference in the outcome of the crawfold and nime5ter methods presented here. Using the crawfold method, if you are playing a song thru Sonos it will be muted or paused by the VC generated announcement but will resume when the announcement is over. nime5ter's method stops the song that is currently playing and that song does not continue when the announcement is over.
Title: Re: Can VC Announcements be Forwarded to SONOS
Post by: nime5ter on October 08, 2014, 10:39:16 PM
Good to know, and it makes sense. For fun, when you have the time, could you test out the following possible alternatives and let us know the outcomes?

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.0.3-->
<commandGroup open="True" name="Different TTS to Sonos tests" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="141" name="Another method for sending TTS" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="This is supposedly an &quot;outdated&quot; function, but it seems like it might be useful. According to the documentation: &quot;This action will pause the current playback, play the alert, and then the playback will be resumed.&quot;">
    <action>
      <cmdType>TTS.Speak2Wav</cmdType>
      <params>
        <param>This is the TTS announcement</param>
        <param>C:\VoxCommando\tts.wav</param>
        <param>False</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Vera.Raw</cmdType>
      <params>
        <param>data_request?id=action&amp;DeviceNum=184&amp;serviceId=urn:micasaverde-com:serviceId:Sonos1&amp;action=Alert&amp;URI=x-file-cifs://192.168.81.191/VoxCommando/tts.wav&amp;Volume=50&amp;Duration=15</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>Another method for sending TTS</phrase>
  </command>
  <command id="145" name="Test the Sonos plugin's built-in TTS" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="According to the plugin documentation &quot;This action will pause the current playback, say the text, and then the playback will be resumed&quot;">
    <action>
      <cmdType>Vera.Raw</cmdType>
      <params>
        <param>data_request?id=action&amp;DeviceNum=184&amp;serviceId=urn:micasaverde-com:serviceId:Sonos1&amp;action=Say&amp;Text=This is the TTS announcement&amp;Language=en</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>Test the Sonos plugin's built-in TTS</phrase>
  </command>
</commandGroup>
Title: Re: Can VC Announcements be Forwarded to SONOS
Post by: crawfofd on October 08, 2014, 11:15:09 PM
nime5ter,

I did a test of your recent xml and both work. 

The addition of the duration in the (alert) made it so that if something was playing already it would mute and play the wav file, then return to playing. It still needs volume control.

The second one (say) does the same thing but returns immediately after is says what is past to it. It seems the best so far. This also needs volume control.

Great work!

Will do some more testing.
Title: Re: Can VC Announcements be Forwarded to SONOS
Post by: crawfofd on October 09, 2014, 12:05:35 AM
nime5ter, I figured the volume out.  You just have to add &Volume=?? (?? 1-99) at the end of your 'say' or 'alert'.
Title: Re: Can VC Announcements be Forwarded to SONOS
Post by: nime5ter on October 09, 2014, 09:06:42 AM
Thanks for testing and reporting back. So the volume parameter adjusts the volume of the TTS message, which is a good idea.

15 seconds is a tad long for "duration". If left unspecified the default is 10 seconds, according to the documentation. Still, it's not an ideal method.

I really just wanted to test the examples provided in the documentation (on the page you linked to: http://code.mios.com/trac/mios_sonos-wireless-music-systems).

The scene method is probably best for most users, but some users might want other kinds of control -- for being able to customize which room/group is targeted, and that kind of thing maybe.

I'm not sure when it will come in handy, but hopefully this thread can give all Sonos users some tools to expand control.