Enabling/disabling plugins from a script

Posted on
Fri Jan 11, 2019 2:15 pm
papamac offline
User avatar
Posts: 25
Joined: Jan 29, 2014

Enabling/disabling plugins from a script

Are there indigo system call to enable and disable plugins from a standalone python script? I would like to disable HomeKit Bridge when my security system is armed and then re-enable it after a disarm. I couldn't find any way of doing this in the documentation.

Thanks,

papamac

Posted on
Fri Jan 11, 2019 2:38 pm
FlyingDiver offline
Posts: 2750
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Enabling/disabling plugins from a script

You mean a python script running as an Indigo action?

Pretty sure this is right:

Code: Select all
plugin = indigo.server.getPlugin("com.flyingdiver.indigoplugin.betteremail")
if plugin.isEnabled():
   plugin.disable()


You'll need the plugin ID for the plugin you actually want to enable/disable. If it's not in the docs, look in the Info.plist inside the plugin wrapper.

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

Posted on
Fri Jan 11, 2019 11:14 pm
kw123 offline
User avatar
Posts: 6252
Joined: May 12, 2013
Location: Dallas, TX

Re: Enabling/disabling plugins from a script

.disable() does not work . -- plugin.restart() -- does.

Has been on my request list for a LONG time.. (sql logger is busy sometimes and then it can't get back to normal - when your DB is big and a dev.state changes from int to real for example . need to disable / enable for 10 secs, then everything is fine. Right now doing this with an applescript key stroke screen commands.. which is not portable and will break if anything changes


===>>>> we need .disable() and .enable() <<<<<====

Posted on
Sat Jan 12, 2019 5:26 am
DaveL17 offline
User avatar
Posts: 4589
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Enabling/disabling plugins from a script

IMO, .enable() and .disable() are a security risk; being able to turn an arbitrary plugin on or off from Python is too dangerous. I don't think that .enable() and .disable() should be made available. However, a plugin developer could effectively add this feature to an individual plugin without too much difficulty (on/off being different than enabled/disabled).

For the OP, you might be able to do what you want using a derivative of this script which enables/disables Indigo devices. I don't believe that HKB has the facility to enable/disable devices through a plugin action, but you could create two custom actions using each bit of the script to turn on/off HKB server devices.

Code: Select all
# To disable all plugin devices
for dev in indigo.devices.iter("com.eps.indigoplugin.homekit-bridge"):
    indigo.device.enable(dev, value=False)

# To enable all plugin devices
for dev in indigo.devices.iter("com.eps.indigoplugin.homekit-bridge"):
    indigo.device.enable(dev, value=True)

# To disable a single device
dev = indigo.devices[369921985]
indigo.device.enable(dev, value=False)

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sat Jan 12, 2019 8:57 am
kw123 offline
User avatar
Posts: 6252
Joined: May 12, 2013
Location: Dallas, TX

Re: Enabling/disabling plugins from a script

I understand the security concern. But I really would like have the sgllogger be able to at least pause.




Sent from my iPhone using Tapatalk

Posted on
Sat Jan 12, 2019 9:22 am
DaveL17 offline
User avatar
Posts: 4589
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Enabling/disabling plugins from a script

kw123 wrote:
I understand the security concern. But I really would like have the sgllogger be able to at least pause.




Sent from my iPhone using Tapatalk

But it's an all or nothing proposition.

I think the better option would be to add a pause feature directly to the SQL Logger plugin rather than opening the door for every plugin.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sat Jan 12, 2019 10:30 am
kw123 offline
User avatar
Posts: 6252
Joined: May 12, 2013
Location: Dallas, TX

Re: Enabling/disabling plugins from a script

I would be very happy.



Sent from my iPhone using Tapatalk

Posted on
Sun Jan 13, 2019 8:10 pm
papamac offline
User avatar
Posts: 25
Joined: Jan 29, 2014

Re: Enabling/disabling plugins from a script

DaveL17, you had a nice suggestion about disabling devices... but it doesn't work with HomeKit Bridge. HomeKit Bridge has only one kind of device, the HomeKit Accessory Server. Disabling this device has the effect of removing the check on the Comms Enabled checkbox, but it does nothing to the server. The server keeps functioning as though nothing happened. I will ask Colorado4Wheeler about this.

Posted on
Mon Jan 14, 2019 3:55 am
DaveL17 offline
User avatar
Posts: 4589
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Enabling/disabling plugins from a script

papamac wrote:
DaveL17, you had a nice suggestion about disabling devices... but it doesn't work with HomeKit Bridge. HomeKit Bridge has only one kind of device, the HomeKit Accessory Server. Disabling this device has the effect of removing the check on the Comms Enabled checkbox, but it does nothing to the server. The server keeps functioning as though nothing happened. I will ask Colorado4Wheeler about this.

Without diving into the code, there may be a simple change that the dev could make in order to honor the comm disabled setting within Indigo. It could be that he simply never envisioned that someone would want the server device to be taken offline.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Mon Jan 14, 2019 5:05 am
siclark offline
Posts: 796
Joined: Jun 13, 2017
Location: UK

Enabling/disabling plugins from a script

I might be missing something here, but don't you just turn off the relevant HKB device. For instance I have all my alarm and motion devices in their own bridge device and can just turn it on and off as required , for instance from triggers based on whether the alarm itself is armed or not.
I'm pretty sure C4W does the same.
That way I can disable some functionality but still check on lights etc. Or I could turn it all off. Why does the whole plugin need disabling?


Sent from my iPhone using Tapatalk

Posted on
Mon Jan 14, 2019 4:42 pm
jay (support) offline
Site Admin
User avatar
Posts: 15146
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Enabling/disabling plugins from a script

Plugins that depend on/wrap existing Indigo devices should most definitely honor when the user disables/enables them using the standard mechanisms. Plugins will get a deviceUpdated message for any device change (assuming they've subscribed to device changes as they should) and they should take appropriate action when they see a device is no longer enabled.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Jan 14, 2019 4:46 pm
jay (support) offline
Site Admin
User avatar
Posts: 15146
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Enabling/disabling plugins from a script

DaveL17 wrote:
IMO, .enable() and .disable() are a security risk; being able to turn an arbitrary plugin on or off from Python is too dangerous.


This is exactly why we only allow restarts of plugins from other plugins/scripts.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests