Efficiently trigger huge script when changes happen

Posted on
Sat Feb 08, 2020 12:56 pm
davinci offline

Efficiently trigger huge script when changes happen

I have over 1000 lines of code that I need to run because I need some variables calculated soon after they change.

The problem is that if I run it every second, IndigoServer goes up to 70% CPU load. 5 seconds brings it below 10%.

How can I trigger the scripts every second but only if there are changes to the variables or devices?
Should I check for the SQLite Database (from SQL Logger) or is there another way?

Posted on
Sat Feb 08, 2020 1:51 pm
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Efficiently trigger huge script when changes happen

Convert it to a plugin.

How many variables are you needing to monitor?

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

Posted on
Sun Feb 09, 2020 1:53 am
davinci offline

Re: Efficiently trigger huge script when changes happen

Should be a few hundred variables and devices.

I found a way with the plugin Group Change Listener.

I change one variable (which I don't select in the plugin) :mrgreen: with a timestamp in milliseconds.
Code: Select all
import time
current_milli_time = int(round(time.time() * 1000))
indigo.variable.updateValue("UpdateIndigoRequested", str(current_milli_time))


Not sure how critical it is since it could trigger 50 times at once...
For now I just delay the execution by a second and remove deleted triggers. This could be critical if I get too many changes within seconds so it never executes...

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 8 guests