Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

SONOS Plugin Official (download here)

Questions and comments specific to a particular plugin should go here.
Post Reply
Telorast
Posts: 46
Joined: Wed Feb 27, 2013 2:44 pm

Re: SONOS Plugin Official (download here)

Post by Telorast »

Is it possible to get information about the current group configuration? Grouping speakers sometimes crashes for me so I don't want to do it if they are already grouped like I want.
techoguy
Experienced User
Posts: 157
Joined: Mon Mar 18, 2013 1:32 am

Re: SONOS Plugin Official (download here)

Post by techoguy »

Telorast wrote:Is it possible to get information about the current group configuration? Grouping speakers sometimes crashes for me so I don't want to do it if they are already grouped like I want.
Hi Telorast,
off hand, it's not particularly easy to get the current group configuration. I don't store that information in easy to retrieve manner. I new command could be created that gets the current group configuration in XML format and returns it in an event payload.

I'm interested to know what errors you are getting when it crashes though. Are you grouping with a coordinator defined (exclusive group) or is that blank? If a coordinator is selected can you try without one?

I run the GroupZP command every morning to reset my groups. I don't think it crashes on me (I say I don't think, because I have EG automatically restarting if something hangs or an error occurs, during the reboot, it does set a light red and email me, but i don't always follow up to see it's cause).
The Latest SONOS Plugin:
Latest version can be found here: http://eventghost.org/forum/viewtopic.p ... 05f#p30309

EventGhost Lets me automate my home the way I want it, I love using it!
Telorast
Posts: 46
Joined: Wed Feb 27, 2013 2:44 pm

Re: SONOS Plugin Official (download here)

Post by Telorast »

It just hangs on the group command, it's the last thing in the log and it never returns. EventGhost still responds, it just can't run any code.

I use it with a coordinator, can try removing it and see how that works.
Greenwald
Posts: 1
Joined: Thu May 21, 2015 6:44 pm

Re: SONOS Plugin Official (download here)

Post by Greenwald »

Any shot of getting this plugin to take two addresses and figure out the optimal route with traffic conditions?

And then speak it over a sonos speaker? Similar to the weather app.
User avatar
yokel22
Experienced User
Posts: 265
Joined: Thu Feb 05, 2015 5:56 pm
Location: U.S. - Kansas city

Re: SONOS Plugin Official (download here)

Post by yokel22 »

I was wondering if it would be possible to add events for when a zone is grouped/ungrouped? What I'm hoping to do is map that event to send On/off & input states to a AV receiver. So my when my sonos connects' are grouped/ungrouped the receiver will act accordingly. This can be done with the current stopped/playing events, it's just not ideal for the task.
techoguy
Experienced User
Posts: 157
Joined: Mon Mar 18, 2013 1:32 am

Re: SONOS Plugin Official (download here)

Post by techoguy »

Greenwald wrote:Any shot of getting this plugin to take two addresses and figure out the optimal route with traffic conditions?

And then speak it over a sonos speaker? Similar to the weather app.
Hi Greenwald, i'm not sure i understand what you are asking for. can you elaborate?
The Latest SONOS Plugin:
Latest version can be found here: http://eventghost.org/forum/viewtopic.p ... 05f#p30309

EventGhost Lets me automate my home the way I want it, I love using it!
techoguy
Experienced User
Posts: 157
Joined: Mon Mar 18, 2013 1:32 am

Re: SONOS Plugin Official (download here)

Post by techoguy »

yokel22 wrote:I was wondering if it would be possible to add events for when a zone is grouped/ungrouped? What I'm hoping to do is map that event to send On/off & input states to a AV receiver. So my when my sonos connects' are grouped/ungrouped the receiver will act accordingly. This can be done with the current stopped/playing events, it's just not ideal for the task.
Hi yokel22, I believe there should be events triggered when groups change. I'll have to double check this.
But, I'm also confused why you can't use the "stopped/playing" events or why it's not ideal. Can you explain more? All Zone players of a group will have a play/stopped trigger for each player regardless if it's grouped or not.

The idea was that you can turn the receiver off and on based on music playing (which is really a zone players "off" and "on" states). If a receiver is turned on only when it's grouped, the receiver could be left on for ever and then if you switch the receiver to say watch TV, then it won't automatically switch back when music starts to play again on SONOS because the group hasn't changed. This was my thought process at least.
The Latest SONOS Plugin:
Latest version can be found here: http://eventghost.org/forum/viewtopic.p ... 05f#p30309

EventGhost Lets me automate my home the way I want it, I love using it!
User avatar
yokel22
Experienced User
Posts: 265
Joined: Thu Feb 05, 2015 5:56 pm
Location: U.S. - Kansas city

Re: SONOS Plugin Official (download here)

Post by yokel22 »

It's just not ideal in my mind because when you hit pause it's gonna toggle the receiver. The event for group is [playing] & [stopped] for ungrouped. It's a small thing, & perfectly livable without it. Ideally I would use both conditionally.
techoguy
Experienced User
Posts: 157
Joined: Mon Mar 18, 2013 1:32 am

Re: SONOS Plugin Official (download here)

Post by techoguy »

yokel22 wrote:It's just not ideal in my mind because when you hit pause it's gonna toggle the receiver. The event for group is [playing] & [stopped] for ungrouped. It's a small thing, & perfectly livable without it. Ideally I would use both conditionally.
HI Yokel22,
I see what you're saying. You can add an egg timer that basically delays the receiver turning off and aborts it all together if the zone player starts playing again. See that solution below. This means if you delay the receiver turning off for say, 10 minutes, then you can pause and play music with out the receiver turning off during the pause.

As for the grouping, there should be events triggering but I just tested this again and i'm not seeing them so either something changed or I accidentally removed them at some point. I'll have to go back and look at the code and see if can add them back.

Here is the EggTimer Example:
In this example, the Zone "stop" event starts a 3 minute timer (can be adjusted to what ever you want). After the timer runs out, it triggers an event that then turns the Receiver off (or sends what ever command you want). If the "play" event is seen within the 3 minutes, the timer is aborted which means the Receiver does not turn off.

First add an EggTimer which is found in the ScheduleGhost Plugin.
Add Macro -> Expand ScheduleGhost -> Select "Start egg timer" -> Fill in the delay you want and add the Egg timer name.
EggTimer Window
EggTimer Window
Then create these other macros and add the corresponding events
Add Macro -> Expand ScheduleGhost -> Select "Abort egg timer by name" -> Fill in the same name used above.
Add Macro to turn off your Receiver, in my case i'm using the HarmonyHub to do this.

In the near future I expect to create a condition that also aborts the receiver turning off if the receiver input has been changed as in the case if someone sits down to watch TV and the receiver changes inputs. This way after the SONOS system stops, it doesn't turn off the receiver.
EggTimer Macros
EggTimer Macros
The Latest SONOS Plugin:
Latest version can be found here: http://eventghost.org/forum/viewtopic.p ... 05f#p30309

EventGhost Lets me automate my home the way I want it, I love using it!
User avatar
yokel22
Experienced User
Posts: 265
Joined: Thu Feb 05, 2015 5:56 pm
Location: U.S. - Kansas city

Re: SONOS Plugin Official (download here)

Post by yokel22 »

That's a good solution. Thanks.
sucre
Posts: 2
Joined: Sun Aug 02, 2015 10:00 am

Re: SONOS Plugin Official (download here)

Post by sucre »

Hi technoguy

Thanks a lot for that great plugin! The only issue I have, is that the listeners seems to stop working after a period of time and the only solution which helps is restarting EG completely. I've read a tread where you talking about restart.asyncCore etc... Have you found a solution therefor or do I have a complete different issue.

In Addition, I've written a few lines of code, to detect if SONOS goes in PAUSED state because of a sleep timer and if it changes to PLAYING state because of an alarm.
Feel free to include if you like ;) (code after line 653)

Code: Select all

        try:
            priv_sleeptimer_obj = xml.getElementsByTagName("r:SleepTimerGeneration")[0]
            if priv_sleeptimer_obj is not None:
                try:
                    if transportstate == "PAUSED_PLAYBACK":
                        if int(priv_sleeptimer_obj.attributes['val'].value) == 0:
                            eg.TriggerEvent(uuid+".Sleep", prefix='SONOS', payload=globalZPList[uuid].name)
                except:
                    if int(priv_sleeptimer_obj.attributes['val'].value) == 0:
                        eg.TriggerEvent(uuid+".TimerUnset", prefix='SONOS', payload=globalZPList[uuid].name)
                    else:
                        eg.TriggerEvent(uuid+".TimerSet", prefix='SONOS', payload=globalZPList[uuid].name)
                    pass
        except:
            pass

        try:
            priv_alarm_obj = xml.getElementsByTagName("r:AlarmRunning")[0]
            print "alarm_obj is: %s" % (priv_alarm_obj)
            if priv_alarm_obj is not None:
                try:
                    if transportstate == "TRANSITIONING":
                        if int(priv_alarm_obj.attributes['val'].value) == 1:
                            eg.TriggerEvent(uuid+".WakeUp", prefix='SONOS', payload=globalZPList[uuid].name)
                except:
                    pass
        except:
            pass
Thanks
sucre
techoguy
Experienced User
Posts: 157
Joined: Mon Mar 18, 2013 1:32 am

Re: SONOS Plugin Official (download here)

Post by techoguy »

Hi Sucre,

When the issue occurs, can you restart the SONOS plugin only and does that fix the problem? I see you say you have to restart EG as a whole but just wanted to make sure you have tried restarting just the plugin. If you really do have to restart EG, then it's probably the AsyncCore problem. When this error occurs it will keep all plugins from successfully communicating over IP. The error can occur from any plugin that uses the AsynCore for IP communication but the SONOS plugin uses it a lot so it seems to cause it to happen more often.
I have never found a solution. I did create a couple of work arounds that help though.

I first use a plugin that watches the log for errors (asyncore errors in this case) and if it's found, it will automatically save EG then restart it and send me an email to let me know. I also use another plugin to output the log to a file so I can go back an look at what happened if i need to.

I also modified the AsyncCore function in the EG code itself to help reduce the occurance. There's also a timing value in the SONOS plugin that you can adjust to help a little too. This issues seems to be more specific to the computer it runs on (speed) so values seem to be different for different users. What causes the issue is if the AsyncCore is called multiple times too quickly together (I think). So What I did is created a time delay that doesn't let the AsyncCore restart for a certain time so if multiple requests come in back to back they all run before re-starting it. This reduced the occurrences for me from about once a day to once every few weeks.

If you want details on how I implemented all of this, let me know and I'll post it all. I'm just not home right now to get the exact code and locations.

As for the additional events you added, i'll add that to the base code. There are other things that I need to fix but have not had time to work on this.
The Latest SONOS Plugin:
Latest version can be found here: http://eventghost.org/forum/viewtopic.p ... 05f#p30309

EventGhost Lets me automate my home the way I want it, I love using it!
sucre
Posts: 2
Joined: Sun Aug 02, 2015 10:00 am

Re: SONOS Plugin Official (download here)

Post by sucre »

Hi Techoguy

Thanks a lot for your quick response. In my case I have to restart EG. If I just restart the Sonos Plugin, it comes up with an error and EG seems to do nothing at all... (find a screenshot attached). Since I restart EG every night it works for the rest of the day. Before EG crashed within 48 hours.

I would be great if you could send me some details about these values and your log file monitoring approach :) This is much more sophisticated than my approach restarting it every 24h hours...

But don't hurry up, I completely understand your situation, it's always the same with the time :D

Cheers
Sucre
Attachments
sonos_plugin_restart_errror.png
DaeronAlagos
Posts: 2
Joined: Fri Jun 21, 2013 4:45 pm

Re: SONOS Plugin Official (download here)

Post by DaeronAlagos »

Awesome work on the plugin Techoguy, thanks for all your hard work :D

Here comes the "I need help" part :wink:

I've got it connecting to my PLAY:3 fine, but when I use the GoogleTTS nothing plays. Everything shows up in the EG event log as expected, there's just no sound. I've tested my set-up by using TrackURI with a url and that works fine. Is it possible to set up a method that will over the network to my PLAY:3, but work more like using the NotificationLineIn method?

I'd actually prefer to use a PC based TTS instead of GoogleTTS, but as I've only got the PLAY:3 I don't have a Line In socket to use.

Thanks again,

Daeron.
DaeronAlagos
Posts: 2
Joined: Fri Jun 21, 2013 4:45 pm

Re: SONOS Plugin Official (download here)

Post by DaeronAlagos »

I've done some further research into this and it looks like the problem is with Google Translate. When I post the generated URL into my browser I get a CAPTCHA, so the Sonos plugin will never be able to get to the Translate page, hence there being no sound played by my speaker. I did find a work-around to send the request to Google with no header information, but haven't got any further with this.

Regarding my other proposed solution, the Sonos cannot wirelessly stream using a Windows sound output (hence why the LineIn option is only available on the PLAY:5 and SoundBar). An alternative method would be to use pyttsx to convert the MS SAPI to a temporary .wav file and then play this on each notification action. I'm not sure what the delay time would be using this method though.

I'll keep looking for/working on answers in the meantime.

Thanks again for this plugin,

Daeron.
Post Reply