Trigger on change of multiple variables

Posted on
Sat Feb 01, 2020 6:02 am
davinci offline

Trigger on change of multiple variables

Is it possible to trigger a python script when a set of variables has any changes? If so how?

If not, is it safe to get the values evaluated every second or even constantly watching the variables?

Posted on
Sat Feb 01, 2020 6:58 am
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Trigger on change of multiple variables

You can trigger on any change in a (one) variable. If you want to monitor several, but run the same script, you'll need to create a trigger for each variable. But you can put the script in an Action Group and then have all those triggers run the same group.
Attachments
Screen Shot 2020-02-01 at 7.57.31 AM.png
Screen Shot 2020-02-01 at 7.57.31 AM.png (415.42 KiB) Viewed 1440 times

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sat Feb 01, 2020 7:11 am
davinci offline

Re: Trigger on change of multiple variables

Yes but I would have to do this for over hundred variables. :mrgreen:

Posted on
Sat Feb 01, 2020 7:16 am
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Trigger on change of multiple variables

davinci wrote:
Yes but I would have to do this for over hundred variables. :mrgreen:


Then you probably need to rethink how you're setting those variables and why you need to monitor them.

Can you explain what you're actually doing with all those variables?

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sat Feb 01, 2020 8:03 am
davinci offline

Re: Trigger on change of multiple variables

I have several devices and depending on their states I want to set a new state to be used in an app.

The calculations should be done on Indigo, not in the app.

Posted on
Sat Feb 01, 2020 8:07 am
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Trigger on change of multiple variables

davinci wrote:
I have several devices and depending on their states I want to set a new state to be used in an app.

The calculations should be done on Indigo, not in the app.


Sorry, can't help. The only other way I know to do this is to write a plugin that monitors the variables.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sat Feb 01, 2020 9:01 am
davinci offline

Re: Trigger on change of multiple variables

Thanks anyway.

Posted on
Sat Feb 01, 2020 9:07 am
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Trigger on change of multiple variables

The only way I know to do this is to use
Code: Select all
        indigo.variables.subscribeToChanges()

Which can only be used in a plugin. I tried to use it in a script, and got an error:
Code: Select all
>>> indigo.variables.subscribeToChanges()
Traceback (most recent call last):
  File "<console>", line 1, in <module>
ValueError: subscribeToChanges can only be called from plugins (not scripts or the interactive shell)
>>>


So you either need a plugin that can use subscribeToChanges(), or you need to use a standard Event Trigger. Unless someone else has written a plugin to do this already. Hmm.

Look what I found: http://www.indigodomo.com/pluginstore/category/4/

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sat Feb 01, 2020 9:33 am
davinci offline

Re: Trigger on change of multiple variables

Group Change Listener looks promising. I will check that.

Thank you a lot!

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 13 guests

cron