Page 2 of 2

Re: how to run a script ONLY ONCE at start of indigo

PostPosted: Thu Apr 26, 2018 10:46 am
by DaveL17
Ignore me. OP says startup which somehow became shutdown in my head.

Never mind.


Sent from my iPhone using Tapatalk

Re: how to run a script ONLY ONCE at start of indigo

PostPosted: Thu Apr 26, 2018 1:36 pm
by Hackencrash
Yes please Karl, I’d love a copy of an Indigo shutdown plugin to trigger a voice announce and email as I’ve been caught out a couple of times where MacOS has updated and not restarted cleanly. No need to productionize it - I’ll take it as is.

I had a rubbish heating script which left the house absolutely boiling hot after failing to run after an OS update - oops!


Sent from my iPhone using Tapatalk

Re: how to run a script ONLY ONCE at start of indigo

PostPosted: Thu Apr 26, 2018 1:54 pm
by jay (support)
I HIGHLY recommend turning off auto updates for just this reason. That way you can update when you can focus your full attention on the whole process (including dealing with issues).

Re: how to run a script ONLY ONCE at start of indigo

PostPosted: Thu Apr 26, 2018 2:49 pm
by kw123
It’s on my GitHub/kw123


Sent from my iPhone using Tapatalk

Re: how to run a script ONLY ONCE at start of indigo

PostPosted: Thu Apr 26, 2018 11:32 pm
by kw123
I know the shutdown plugin is a work around.. and yes it will fire if its reloaded .. that why there is the enable variable test included.. But a regular indigo event would be really nice and ?easy to do?..

.. is there a log file entry when indigo shuts down? we could use that one for an "and" trigger

Karl

Re: how to run a script ONLY ONCE at start of indigo

PostPosted: Fri Apr 27, 2018 10:14 am
by jay (support)
kw123 wrote:
But a regular indigo event would be really nice and ?easy to do?..


Not necessarily easy. The problem is how long should the server wait on actions fired from a shutdown trigger until it kills them? If, for instance, the action on the shutdown trigger fired an external script (which could run forever), how long should it wait until it kills the script and continues the shutdown? What if it gets the shutdown notification from the OS rather than from the client? Perhaps the shutdown came from a UPS where the battery is about to go out so you'd want the server to shut down quickly (but we don't know the circumstances for the shutdown request).

So, technically, it would be pretty simple to generate the event itself. But the problem is what happens after the server fires the actions for the event(s). I'm sure there are other reasons why doing a shutdown trigger is tricky. And, honestly, demand has been quite low anyway so it's an easy one to kick down the road.

Re: how to run a script ONLY ONCE at start of indigo

PostPosted: Fri Apr 27, 2018 12:39 pm
by kw123
I understand the issues.. but still need one .

So I will stick with the little plugin and will add a logfile scan (tail -1000) scanning for indigo shutdown ..

Karl

Re: how to run a script ONLY ONCE at start of indigo

PostPosted: Fri Apr 27, 2018 5:28 pm
by kw123
Tuned the plugin a little:
now checks if "Quitting Indigo Server - stopping plugins" is in the last 400 lines of the indigo logfile and is not followed by "Loading plugin"
Only then AND if the variable "shutdownActionEnabled" is set to 1, true, or yes the shutdown action is performed.

Karl

github.com/kw123