how to run a script ONLY ONCE at start of indigo

User avatar
DaveL17
Posts: 7323
Joined: Tue Aug 20, 2013 11:02 am
Location: Chicago, IL, USA
Contact:

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

Post by DaveL17 »

Ignore me. OP says startup which somehow became shutdown in my head.

Never mind.


Sent from my iPhone using Tapatalk
I came here to drink milk and kick ass....and I've just finished my milk.

My Plugins and Scripts
User avatar
Hackencrash
Posts: 251
Joined: Wed Dec 16, 2015 7:05 am
Location: UK

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

Post 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
User avatar
jay (support)
Site Admin
Posts: 19232
Joined: Wed Mar 19, 2008 11:52 am
Location: Austin, Texas
Contact:

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

Post 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).
Jay (Indigo Support)
Twitter | Facebook | LinkedIn
User avatar
kw123
Posts: 8705
Joined: Sun May 12, 2013 4:44 pm
Location: Dallas, TX
Contact:

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

Post by kw123 »

It’s on my GitHub/kw123


Sent from my iPhone using Tapatalk
User avatar
kw123
Posts: 8705
Joined: Sun May 12, 2013 4:44 pm
Location: Dallas, TX
Contact:

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

Post 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
User avatar
jay (support)
Site Admin
Posts: 19232
Joined: Wed Mar 19, 2008 11:52 am
Location: Austin, Texas
Contact:

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

Post 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.
Jay (Indigo Support)
Twitter | Facebook | LinkedIn
User avatar
kw123
Posts: 8705
Joined: Sun May 12, 2013 4:44 pm
Location: Dallas, TX
Contact:

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

Post 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
User avatar
kw123
Posts: 8705
Joined: Sun May 12, 2013 4:44 pm
Location: Dallas, TX
Contact:

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

Post 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
Post Reply

Return to “Karl's Plugins and Scripts”