How to question: Trigger on Zoneplayer state?

Posted on
Tue Aug 07, 2018 11:03 am
dduff617 offline
Posts: 403
Joined: Jul 05, 2006

How to question: Trigger on Zoneplayer state?

I recently added a Sonos Connect called "SC" to my Sonos system and I'd like to make it so that when I include that player in a group and use it to play music, I want my AV system to do the right thing. My AV system is connected to a Harmony hub, so I'm using Harmony plugin to control. So I want to detect when SC goes from an idle state to playing (any source, either as leader or as a member of a group) and in that case, I'll use Harmony plugin to select the "sonos" harmony activity that I've setup to select appropriate input, volume, audio settings, etc.

I observed the detailed state info for my zone players in Indigo as they changed with various actions - starting, stopping, etc. I noted that ZP_STATE seemed to change when unit was playing. As a simple experiment, the first thing I tried was having a trigger in Indigo for when state becomes "PLAYING". This did not seem to work, so I presume that either ZP_STATE visible in Indigo is not the same as the "State" that I can choose from the menu of states I see in setting up a device-state-changed trigger OR that matching it with a simple becomes-equal-to test of a simple string "PLAYING" is not the right way to detect the change I'm looking for. So my first question: what is the right kind of trigger to use for detecting when a zone player starts playing?

As an aside, I see that there is a different type of trigger available, seemingly specific to Sonos that is "Zoneplayer Available" or "Zoneplayer Unvailable" that offer no configuration and seem not to be specific to a Sonos device, so they don't look like they would be applicable. However, I'm curious - what do these trigger conditions represent and how are they used?

Finally, are there any online docs for Sonos plugin?

Posted on
Tue Aug 07, 2018 11:28 am
dduff617 offline
Posts: 403
Joined: Jul 05, 2006

Re: How to question: Trigger on Zoneplayer state?

the first thing I tried was having a trigger in Indigo for when state becomes "PLAYING". This did not seem to work


this turned out to be a dumb user error. the trigger i was using to test had been set to disabled, causing me a lot of needless confusion. so disregard this part of my original question. i'll post further updates as i refine the solution.

Posted on
Tue Aug 07, 2018 2:36 pm
dduff617 offline
Posts: 403
Joined: Jul 05, 2006

Re: How to question: Trigger on Zoneplayer state?

Ok, so I have gone ahead with my simple experiment. I set up a trigger set so that when SC, the Sonos zone that's attached to my AV system has it's State changed to "PLAYING", my Harmony system switches to it's "sonos" activity. This works. The Harmony handles a lot of the messy details. For example, selecting sonos activity means if the system is off, it it turns on my receiver and subwoofer, and if it's in a different activity (such as watching TV or listening to a CD), it switches inputs to select the optical input from the sonos device, turns off the TV, etc. So this part seems to work well.

So the key questions for me to get beyond this limited experiment to something that really works are 1) exactly how to tell when to initiate the sonos activity, and 2) how to tell when to turn the system off.

Some observations out of the gate: when the SC is grouped with a Play One that's being used for Airplay, the state of SC is <blank>. The state of the other Play One that's the group leader is also blank. So it seems that using state="PLAYING" as the trigger is not going to cut it as a basis for my trigger for key question #1.

Also regarding question #2... Even aside from the above problem, turning the system off any time the SC device state becomes anything other than "PLAYING" is not ideal - for example, I sometimes want to pause the music briefly (to answer phone or whatever) and I'd prefer to not incur the delay associated with a complete turn-on when I want to resume playing in that case. Also, I observe that when switching the selected streaming source, the state becomes "TRANSITIONING" for a few seconds, so that's not going to work very well either.

Has anyone tried anything like this and have ideas to share?

Posted on
Tue Aug 07, 2018 4:41 pm
Londonmark offline
Posts: 320
Joined: Feb 29, 2012

Re: How to question: Trigger on Zoneplayer state?

Really interested in this. Have just bought a Harmony Hub and have a Sonos Connect plugged into my amp. Previously the amp has been always on and set to the Sonos input by default. However this sounds like a better approach - if we can overcome the blank state issue.

Posted on
Sun Aug 12, 2018 1:10 pm
vtmikel offline
Posts: 338
Joined: Aug 31, 2012
Location: Boston, MA

Re: How to question: Trigger on Zoneplayer state?

I do this regularly, so I'm happy to help where I can.

My trigger is on ZP_STATE being set to "PLAYING".

My conditions for this are (any of the following are true):
My Onkyo AVR is off
Current input for Zone 1 is not set to the Sonos
Current input for zone 2 is not set to the Sonos

Actions:
Turn on AVR
Set input for Zone 1
Set input for Zone 2
Set volume to static level (I use Sonos for volume)

My trigger for turning the AVR back off uses the Group Listener plugin. For my house, the AVR either has the TV audio, or is set the Sonos. I monitor the TV onOffState, as well as the status of the Sonos. If neither is doing something, I turn off the AVR. I do this with a custom python script, though it should be possible just using conditions. Short pauses in the music will trigger the AVR to be turned off, but I've never found it to be a bother since the On trigger (above) will simply fire again. However, when implemnting this using a python script as the action, you can set a delay, when the script executes, it may see that the Sonos is now playing something again, avoiding the unnecessary "off" command.

Also, an important note: I enforce the group state of my Sonos configuration with Indigo as well. This way, I know I can always monitor the main coordinator for its ZP_STATE. I have another action group that will reset the group configuration if it sees it to be misaligned.

I dont find myself using Airplay, so I cant really help there.

I do restart the Sonos plugin daily to increase the effectiveness of this approach. It's been rock solid for me.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest