Advanced Sonos Control -- many triggers or code?

Posted on
Mon Nov 30, 2015 11:40 pm
Ramias offline
Posts: 272
Joined: Nov 24, 2015

Advanced Sonos Control -- many triggers or code?

I am new to Indigo and am trying to recreate some functionality I had with Vera.

There I had a LUA script I wrote that when triggered:

Checked a variable to see if sonos had been paused in the previous n minutes. If so, resume. If not, then:

Depending on the day of the week, the time of that day, and what month (I.e. Christmas Music on Sunday's in December) play a certain Sonos favorite. Tunes on Saturday, morning drive show weekday mornings etc.

In LUA that was just one script.

What is the best way to do that on the Indigo platform? Set up many triggers with specific conditions?
Lone trigger with code that runs? Any pointers on how to do this kind of Sonos control from a Mac script?

Further, I use multiple triggers to do the same thing. Alarm disarmed with a certain code, voice to Alexa, zwave minimote, Lutron wall keypad...

Seems I can on,y have one trigger event per trigger. If each one needs five different options to account for different conditions, it can get quite messy. So I am thinking a code solution is ideal. Then I could just have five separate triggers that execute the samesingle action group(that calls code with a case statement or whatever it is in Python)

Posted on
Tue Dec 01, 2015 4:56 am
DaveL17 offline
User avatar
Posts: 6756
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Advanced Sonos Control -- many triggers or code?

One way to do this would be to use a Python script and use a method called subscribeToChanges(). With this method, you could watch for specific changes to the device and execute your actions based on whatever has happened. In Psuedocode:

Code: Select all
if A happens:
    do B
if C happens:
    do D

http://wiki.indigodomo.com/doku.php?id=indigo_6_documentation:object_model_reference
Dave

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Tue Dec 01, 2015 11:28 am
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Advanced Sonos Control -- many triggers or code?

You can't use subscribeToChanges() in a script - only in a plugin - because the plugin has to implement the methods that are called by the server whenever a change is made.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Dec 01, 2015 12:53 pm
DaveL17 offline
User avatar
Posts: 6756
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Advanced Sonos Control -- many triggers or code?

Crud. Thanks for catching that Jay.


Sent from my iPhone using Tapatalk

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Tue Dec 01, 2015 5:23 pm
Ramias offline
Posts: 272
Joined: Nov 24, 2015

Re: Advanced Sonos Control -- many triggers or code?

So in this case I guess I'm looking at just a simple trigger that calls a script, with all logic happening in the script and the script not reporting back to Indigo? (Indigo could still query the Sonos directly for info needed).

Looks like time to get smart on: http://python-soco.com/

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 6 guests