Reload, enable, disable plugin via trigger action / script?
Forum rules
This is a legacy forum which is locked for new topics. New topics should be started in one of the other forums under Extending Indigo
This is a legacy forum which is locked for new topics. New topics should be started in one of the other forums under Extending Indigo
Reload, enable, disable plugin via trigger action / script?
How would one enable/disable/reload a plugin via a trigger action / embedded script? I can't seem to find any applescript or python equivalent to the menu items Plugins---->(specific plugin)---->[enable][disable][reload], nor are those commands available as actions.
Re: Reload, enable, disable plugin via trigger action / scri
Try Menu scripting.
- matt (support)
- Site Admin
- Posts: 21542
- Joined: Mon Jan 27, 2003 1:17 pm
- Location: Texas
- Contact:
Re: Reload, enable, disable plugin via trigger action / scri
You can, via an embedded Indigo python script, restart a plugin if (and only if) it is already enabled:
Code: Select all
plugin = indigo.server.getPlugin("com.perceptiveautomation.indigoplugin.easydaq-usb-relay-cards")
if plugin.isEnabled():
plugin.restart()Re: Reload, enable, disable plugin via trigger action / scri
So, is there any reason that a plugin could/should not cause it self to reload by invoking the restart method on itself? This would be desirable in a case where a configuration change has been made that requires a plugin restart.support wrote:You can, via an embedded Indigo python script, restart a plugin if (and only if) it is already enabled:Code: Select all
plugin = indigo.server.getPlugin("com.perceptiveautomation.indigoplugin.easydaq-usb-relay-cards") if plugin.isEnabled(): plugin.restart()
- matt (support)
- Site Admin
- Posts: 21542
- Joined: Mon Jan 27, 2003 1:17 pm
- Location: Texas
- Contact:
Re: Reload, enable, disable plugin via trigger action / scri
Hmmm... good question. I don't think it will be ideal. The restart call is going to block until Indigo Server has finished stopping/starting the plugin, but it won't be able to stop it while it is blocked, which will result in the Indigo Server force killing it. I could probably add an optional doNotBlock parameter to the restart method that would make it cleaner...
- matt (support)
- Site Admin
- Posts: 21542
- Joined: Mon Jan 27, 2003 1:17 pm
- Location: Texas
- Contact:
Re: Reload, enable, disable plugin via trigger action / scri
In the next release (5.0.3, not yet available), try passing in a waitUntilDone argument of False and I think it will work smoothly:
Code: Select all
plugin.restart(waitUntilDone=False)Re: Reload, enable, disable plugin via trigger action / scri
Great! That will be a nice help - its always better to have the software do something when it can instead of relying on the user to perform some required task.
Looking forward to 5.0.3
Looking forward to 5.0.3
- jay (support)
- Site Admin
- Posts: 19232
- Joined: Wed Mar 19, 2008 11:52 am
- Location: Austin, Texas
- Contact:
Re: Reload, enable, disable plugin via trigger action / scri
Just curious - what configuration change would require the plugin to restart rather than the plugin logic just adjust to the new change?
Re: Reload, enable, disable plugin via trigger action / scri
In the ad2usb plugin users can change between USB and serial connectivity and between two modes of operation: basic and advanced (with different internal data structures). I currently support closedPrefsConfigUi() and try to do the right thing. It works generally, but still, in both cases, I have reports of error messages thrown. This happens in some installations and not others.
Given a rich test lab (OS version, ad2usb board/firmware version, and panel model), I could probably engineer around all possibilities. But, a restart is clean and avoids the chance of error.
Given a rich test lab (OS version, ad2usb board/firmware version, and panel model), I could probably engineer around all possibilities. But, a restart is clean and avoids the chance of error.
Re: Reload, enable, disable plugin via trigger action / scri
I copied you code into an action group and it worked restarting the easydaq plugin. However when I replaced easydaq with another plugin nothing happened? Does a plugin have to allow this or some other feature to work. It is enabled and I checked the syntax and have tried on a couple of plugins.
I must be doing something wrong when I replace the plugin name (am getting from plugin file name). I have never used an embedded Indigo python script before so maybe I am missing a step? If I change the plugin name do I have to compile or something else.
I have a feeling I am going to feel very dumb when I find the problem but for now I am stumped
I must be doing something wrong when I replace the plugin name (am getting from plugin file name). I have never used an embedded Indigo python script before so maybe I am missing a step? If I change the plugin name do I have to compile or something else.
I have a feeling I am going to feel very dumb when I find the problem but for now I am stumped
- jay (support)
- Site Admin
- Posts: 19232
- Joined: Wed Mar 19, 2008 11:52 am
- Location: Austin, Texas
- Contact:
Re: Reload, enable, disable plugin via trigger action / scri
You have to get the right plugin object first - to get the plugin instance you have to use the plugin's complete ID. It should be specified in the plugin's documentation, but it can be found inside the Info.plist inside the plugin bundle.
Re: Reload, enable, disable plugin via trigger action / scri
Thanks Jay
That did it (after I figured out you had to replace from the " and not just the name
)
Indigo really is a super app!!!
Terry
That did it (after I figured out you had to replace from the " and not just the name
Indigo really is a super app!!!
Terry
Re: Reload, enable, disable plugin via trigger action / scri
I guess self.restart(waitUntilDone=False) didn't make it into 5.0.3
Jan 31, 2012 19:25:07
Starting Indigo Server version 5.0.3
... ...
<type 'exceptions.TypeError'>: restart() got an unexpected keyword argument 'waitUntilDone'
Jan 31, 2012 19:25:07
Starting Indigo Server version 5.0.3
... ...
<type 'exceptions.TypeError'>: restart() got an unexpected keyword argument 'waitUntilDone'
- matt (support)
- Site Admin
- Posts: 21542
- Joined: Mon Jan 27, 2003 1:17 pm
- Location: Texas
- Contact:
Re: Reload, enable, disable plugin via trigger action / scri
Instead of calling restart() on self, try getting the plugin via:
And then plugin.restart() should take the new argument.
Code: Select all
plugin = indigo.server.getPlugin("some.plugin.id.here")Re: Reload, enable, disable plugin via trigger action / scri
Yup. That worked. Thanks!!support wrote:... try
plugin = indigo.server.getPlugin("some.plugin.id.here")
And then plugin.restart() should take the new argument.
