how to run a script ONLY ONCE at start of indigo
how to run a script ONLY ONCE at start of indigo
Has someone figured out how to run eg a script (or action ...) only ONCE at startup?
setting a variable to "started" does not work as you need to reset it when indigo shuts down .. and there is no mechanism for that either ..
anyway looking for suggestions.
Karl
setting a variable to "started" does not work as you need to reset it when indigo shuts down .. and there is no mechanism for that either ..
anyway looking for suggestions.
Karl
- Colorado4Wheeler
- Posts: 2794
- Joined: Mon Jul 20, 2009 10:48 am
- Location: Colorado
Re: how to run a script ONLY ONCE at start of indigo
Why not write a file to the filesystem?
My Modest Contributions to Indigo:
HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy
Check Them Out Here
HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy
Check Them Out Here
- jay (support)
- Site Admin
- Posts: 19232
- Joined: Wed Mar 19, 2008 11:52 am
- Location: Austin, Texas
- Contact:
- Colorado4Wheeler
- Posts: 2794
- Joined: Mon Jul 20, 2009 10:48 am
- Location: Colorado
Re: how to run a script ONLY ONCE at start of indigo
Wow, I didn't even know that was a thing. I love learning new tricks.jay (support) wrote:Run it from an Indigo Server Startup trigger?
My Modest Contributions to Indigo:
HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy
Check Them Out Here
HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy
Check Them Out Here
- 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
LOL - been in there since Indigo 2 I believe.Colorado4Wheeler wrote:Wow, I didn't even know that was a thing. I love learning new tricks.jay (support) wrote:Run it from an Indigo Server Startup trigger?
- Colorado4Wheeler
- Posts: 2794
- Joined: Mon Jul 20, 2009 10:48 am
- Location: Colorado
Re: how to run a script ONLY ONCE at start of indigo
While I would like to know every last possible thing that I can code into Indigo, I'm not you
. Besides, that's a pretty obscure little technique that I bet hasn't been used by many and glazed over by most when reading the docs
.
My Modest Contributions to Indigo:
HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy
Check Them Out Here
HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy
Check Them Out Here
- 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
Actually, it's probably the best way to start up stay-open scripts (things that query data sources, populate variables, etc.) that should pretty much always be running while the server is running. We recommended it for background scripts like the old iTunes Sync script for example.Colorado4Wheeler wrote:While I would like to know every last possible thing that I can code into Indigo, I'm not you![]()
. Besides, that's a pretty obscure little technique that I bet hasn't been used by many and glazed over by most when reading the docs
![]()
.
Re: how to run a script ONLY ONCE at start of indigo
thats great !!
Now how about when indigo shuts down ..
how about a basic plugin that runs, does nothing, Only when indigo shuts it down it does an action when
would that work?
Now how about when indigo shuts down ..
how about a basic plugin that runs, does nothing, Only when indigo shuts it down it does an action when
Code: Select all
try:
while True:
time.sleep(10)
except: pass
###do the action here - 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
Or implement the shutdown() method:
It would just have to do whatever it wanted to do quickly since I think we only wait for a plugin to shut down gracefully for 10 seconds.
Code: Select all
def shutdown(self):
# do any cleanup necessary before exitingRe: how to run a script ONLY ONCE at start of indigo
Can shutdown() still call/ execute an indigo action ?
Sent from my iPhone using Tapatalk
Sent from my iPhone using Tapatalk
Re: how to run a script ONLY ONCE at start of indigo
Yes it can and it works fine.
Have written a plugin if anyone is interested
Sent from my iPhone using Tapatalk
Have written a plugin if anyone is interested
Sent from my iPhone using Tapatalk
Re: how to run a script ONLY ONCE at start of indigo
I never thought about using shutdown() with a server shutdown, but that makes sense. Do running plugins always shut down in alphabetical order? If that's the case, would "zzzPlugin" be "guaranteed" last to go?
I came here to drink milk and kick ass....and I've just finished my milk.
My Plugins and Scripts
My Plugins and Scripts
- 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
First, remember that shutdown() will also be called if the plugin is disabled or restarted - so you're not guaranteed that the server is also shutting down.DaveL17 wrote:I never thought about using shutdown() with a server shutdown, but that makes sense. Do running plugins always shut down in alphabetical order? If that's the case, would "zzzPlugin" be "guaranteed" last to go?
There is no explicit order of plugin shutdowns (that is, there is an order, but we don't publish it because it probably will change periodically as we do more backend server work so you shouldn't assume there is).
Re: how to run a script ONLY ONCE at start of indigo
Thanks Jay. Then the trigger seems like the best bet to key on a server shutdown.
Sent from my iPhone using Tapatalk
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
My Plugins and Scripts
- 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
Unfortunately, at the moment there isn't a Server Shutdown trigger that corresponds to the Server Startup trigger. It's been on the list for many years, but just doesn't seem to have a very high demand.