Author Topic: Sonos commands: Via EventGhost plugin  (Read 4962 times)

0 Members and 1 Guest are viewing this topic.

yokel

  • Jr. Member
  • **
  • Posts: 26
  • Karma: 2
    • View Profile
Sonos commands: Via EventGhost plugin
« on: May 09, 2015, 09:12:07 AM »
Guys.  I was looking through the EG Sonos plugin python & I don't think the dev would be happy with me posting this here.  So i removed the content.   
« Last Edit: May 09, 2015, 04:15:16 PM by yokel »

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Sonos commands: Via EventGhost plugin
« Reply #1 on: May 10, 2015, 06:41:30 PM »
What?  Why?  Everything in EventGhost including any plugin submitted is open source AFAIK but in any case you were only talking about how to work with EventGhost not exploiting anything.  I can't think of anything in your post that anyone would object to.

I was just coming back to reread this post because I think you had a question.  Is there still something you need help with?

I tried to use the EventGhost plugin and had limited success with it.  It was able to play some of my favourites but not all of them.  I'm not sure how I felt about having to specify a zone in each action.  In my mind it makes more sense to specify a zone to control once and then have subsequent commands applied to that zone.

In any case, I was pleased to see you sharing your solution with the community, and I'm sorry you took it down.

As it happens, I am currently working on a VC plugin for Sonos that is going to be awesome.  I've already got it doing some great stuff but there is a lot of work left to do on it.

OklahomaGreyBeard

  • Contributor
  • ***
  • Posts: 54
  • Karma: 3
    • View Profile
Re: Sonos commands: Via EventGhost plugin
« Reply #2 on: May 13, 2015, 07:03:45 PM »
I've been trying to figure out a cheaper home brew alternative to sonos but am wondering if it's worth the cost for something that just works.  I'm assuming since you're writing the plugin, you have some. Is it (or will it be) possible to send the TTS  to different zones? ie: if the request comes in from VW on a tablet assigned to zone 3 (master bedroom) then TTS responses would automatically be routed to that sonos speaker?

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Sonos commands: Via EventGhost plugin
« Reply #3 on: May 13, 2015, 08:25:27 PM »
I find Sonos pretty expensive for what you get but the system does seem to work quite well and is easy to set up and use.  If you have the cash, I think it's a pretty good option.

I also find it a bit of an energy waster.  Each unit is using about 8 watts all the time, whether you are listening to music or not.  Some people will not care about this at all though.

As for your question about TTS, yes it should be possible.  I only have a single Play 3 at the moment so it's a bit hard to test and develop for multi zone stuff.  Maybe it will be possible to make do with user feedback.  Buying another Sonos at the current price would not be my first choice.

yokel

  • Jr. Member
  • **
  • Posts: 26
  • Karma: 2
    • View Profile
Re: Sonos commands: Via EventGhost plugin
« Reply #4 on: May 20, 2015, 11:07:21 PM »
What?  Why?  Everything in EventGhost including any plugin submitted is open source AFAIK but in any case you were only talking about how to work with EventGhost not exploiting anything.  I can't think of anything in your post that anyone would object to.

I was just coming back to reread this post because I think you had a question.  Is there still something you need help with?

I tried to use the EventGhost plugin and had limited success with it.  It was able to play some of my favourites but not all of them.  I'm not sure how I felt about having to specify a zone in each action.  In my mind it makes more sense to specify a zone to control once and then have subsequent commands applied to that zone.

In any case, I was pleased to see you sharing your solution with the community, and I'm sorry you took it down.

As it happens, I am currently working on a VC plugin for Sonos that is going to be awesome.  I've already got it doing some great stuff but there is a lot of work left to do on it.

I was just now rereading this thread.  There isn't anything in the thread that wasn't kosher, feel free to resurrect the original post if you can.  It was a just some wording in the eg sonos plugin that gave me the idea the dev may  not have appreciated it.  That probably isn't the case, i just didn't want to step on anyone's toes. 

My setup is with a whole room mic.  Any subsequent commands will never be registered over playing music.  That's why i specified the room within each play command.  To get all of your favorites, it's easiest to set them up with the EG Sonos plugin.  Then you can just copy/paste the python to find out what the url is. 

TTS through sonos is way to slow to really be effective.  It has to buffer up the stream.  It works well for alerts.  I have timers,call/sms alerts, & my doorbell routed to a few zones. 

My question was re guarding  if/then statements.  I have 4 zones that are run off AV receivers, so when those zones are chosen it needs to also send an additional command to power on the av receiver.  I haven't had much time to play with it but the code below is how i have it working now(I'm sure there's a better way).  In the a=b statement {the Basement} = a zone that needs to have an additional command sent to power on the AV receiver.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.4.5-->
<command id="454" name="Play music Genre" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Sound.MicMute</cmdType>
    <params />
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.SetVar</cmdType>
    <params>
      <param>genre</param>
      <param>{PF.1}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.SetVar</cmdType>
    <params>
      <param>room</param>
      <param>{PF.2}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.SetVar</cmdType>
    <params>
      <param>room</param>
      <param>{PF.2}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.SetVar</cmdType>
    <params>
      <param>genreid</param>
      <param>{1}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.SetVar</cmdType>
    <params>
      <param>zone</param>
      <param>{1}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)==(B)</ifType>
    <ifParams>{PF.2}&amp;&amp;in the basement</ifParams>
    <then>
      <action>
        <cmdType>Group.Disable</cmdType>
        <params>
          <param>Sonos</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>Hue.Light</cmdType>
        <params>
          <param>11</param>
          <param>"alert":"select"</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>EventGhost.Send</cmdType>
        <params>
          <param>[tts]</param>
          <param>Okay. I'll start some {var.genre} tunes in {var.room}</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>EventGhost.Send</cmdType>
        <params>
          <param>Sonos.playlist</param>
          <param>{var.genreid}</param>
          <param>Sonos Playlist</param>
          <param>{var.genre}</param>
          <param>{var.zone}</param>
          <param>{var.room}</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else>
      <action>
        <cmdType>Group.Disable</cmdType>
        <params>
          <param>Sonos</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>Hue.Light</cmdType>
        <params>
          <param>11</param>
          <param>"alert":"select"</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>EventGhost.Send</cmdType>
        <params>
          <param>[tts]</param>
          <param>Okay. I'll start some {var.genre} tunes in {var.room}</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>EventGhost.Send</cmdType>
        <params>
          <param>Sonos.playlistB</param>
          <param>{var.genreid}</param>
          <param>Sonos Playlist</param>
          <param>{var.genre}</param>
          <param>{var.zone}</param>
          <param>{var.room}</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </else>
  </if>
  <action>
    <cmdType>VC.SetEventTimer</cmdType>
    <params>
      <param>4</param>
      <param>UnMuteMic</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Hue.Light</cmdType>
    <params>
      <param>11</param>
      <param>"alert":"select"</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>Play</phrase>
  <phrase optional="true">some</phrase>
  <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\Sonos Genre.xml</payloadFromXML>
  <phrase>music in</phrase>
  <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\Sonos locations.xml</payloadFromXML>
</command>
« Last Edit: May 20, 2015, 11:10:12 PM by yokel »

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Sonos commands: Via EventGhost plugin
« Reply #5 on: May 28, 2015, 08:27:34 AM »
Hi Yokel,  Sorry for the delay in responding.

Do you have an actual question here?  Looking at your macro, I could probably suggest some improvements but without seeing the rest of your groups it is hard to say.

1 - Why are you setting all those variables?  Do you use them in some other commands, or are you just doing it to make your macro easier to read / so you can keep track of what each payload is for while editing the macro?

2 - In the if / then block you are doing almost all the same things in both the then and the else portions.  It would probably make more sense to only put the unique action(s) in the the logic block to make your command shorter and easier to read.

3 - The hue light alert action is sent twice for some reason.

4 - You are disabling the Sonos group, but I'm not sure why.  Again without seeing the rest I can't really say.  Presumably you re-enable it in some other command.

5 - You are setting a variable "zone" to the value of the genre ID and then passing this as a payload to EventGhost.  This must be a mistake.  My guess is that you never use this variable so you didn't notice any ill effect.

6 - The "room" variable gets set twice.  No real problem there.

Based on this and some assumptions, I've honed the command down to a much shorter equivalent.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.3.7-->
<command id="470" name="Play music Genre" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Sound.MicMute</cmdType>
    <params />
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Group.Disable</cmdType>
    <params>
      <param>Sonos</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Hue.Light</cmdType>
    <params>
      <param>11</param>
      <param>"alert":"select"</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>EventGhost.Send</cmdType>
    <params>
      <param>[tts]</param>
      <param>Okay. I'll start some {PF.1} tunes in {PF.2}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)==(B)</ifType>
    <ifParams>{PF.2}&amp;&amp;in the basement</ifParams>
    <then>
      <action>
        <cmdType>EventGhost.Send</cmdType>
        <params>
          <param>Sonos.playlist</param>
          <param>{1}</param>
          <param>Sonos Playlist</param>
          <param>{PF.1}</param>
          <param>not really the zone</param>
          <param>{PF.2}</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else>
      <action>
        <cmdType>EventGhost.Send</cmdType>
        <params>
          <param>Sonos.playlistB</param>
          <param>{1}</param>
          <param>Sonos Playlist</param>
          <param>{PF.1}</param>
          <param>not really the zone</param>
          <param>{PF.2}</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </else>
  </if>
  <action>
    <cmdType>VC.SetEventTimer</cmdType>
    <params>
      <param>4</param>
      <param>UnMuteMic</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>Play</phrase>
  <phrase optional="true">some</phrase>
  <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\Sonos Genre.xml</payloadFromXML>
  <phrase>music in</phrase>
  <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\Sonos locations.xml</payloadFromXML>
</command>

In the end the only difference I can see is that the basement is getting sent an event named "Sonos.playlist" and for any other zone you are sending an event "Sonos.playlistB" but with all the same payloads.  I'm not sure what the EventGhost macro is doing with these events and payloads so I can't suggest anything else at this point.

I hope this helps somehow.

yokel

  • Jr. Member
  • **
  • Posts: 26
  • Karma: 2
    • View Profile
Re: Sonos commands: Via EventGhost plugin
« Reply #6 on: June 12, 2015, 05:22:19 AM »
Sorry James.  Thanks for responding.  It really wasn't a question, more i just need to learn better practices within VC. I'm sure alot of that was gibberish to you ;D.  I ended up solving the problem much simpler.  The Sonos EG plugin generates events for stopped/playing.  Tailor made for my situatiion(variably switching an AVR). 

2exclusive

  • Contributor
  • ***
  • Posts: 54
  • Karma: 0
    • View Profile
Re: Sonos commands: Via EventGhost plugin
« Reply #7 on: June 23, 2015, 07:56:23 PM »
What?  Why?  Everything in EventGhost including any plugin submitted is open source AFAIK but in any case you were only talking about how to work with EventGhost not exploiting anything.  I can't think of anything in your post that anyone would object to.

I was just coming back to reread this post because I think you had a question.  Is there still something you need help with?

I tried to use the EventGhost plugin and had limited success with it.  It was able to play some of my favourites but not all of them.  I'm not sure how I felt about having to specify a zone in each action.  In my mind it makes more sense to specify a zone to control once and then have subsequent commands applied to that zone.

In any case, I was pleased to see you sharing your solution with the community, and I'm sorry you took it down.

As it happens, I am currently working on a VC plugin for Sonos that is going to be awesome.  I've already got it doing some great stuff but there is a lot of work left to do on it.

Working on a Sonos plugin will be awesome, I like how vox commando and event ghost plugin work but it's a pain to setup tts to Sonos via sending broadcast to eg all the time.

Will we expect this soon? This will definitely be a huge plus!!! Thanks James

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Sonos commands: Via EventGhost plugin
« Reply #8 on: June 23, 2015, 09:22:34 PM »
You might want to follow us on twitter or Google+.  This was released on June 6th and updated yesterday.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Sonos commands: Via EventGhost plugin
« Reply #9 on: June 23, 2015, 09:24:07 PM »
btw, there is only support for a desktop TTS voice for now.  I personally don't like the sound of the Google voice but the main issue is that it is much slower than using a local voice.

2exclusive

  • Contributor
  • ***
  • Posts: 54
  • Karma: 0
    • View Profile
Re: Sonos commands: Via EventGhost plugin
« Reply #10 on: June 30, 2015, 06:27:31 PM »
Ok great, I will check it out. I currently use speak2wav and then send a broadcast to eg to playback the file so I can keep my tts voice. With the plugin can you just output the tts directly to sonos?

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Sonos commands: Via EventGhost plugin
« Reply #11 on: June 30, 2015, 06:49:53 PM »
Yes.