Python Scripting Support for Triggers?

Posted on
Fri Feb 09, 2018 1:52 am
masterchief offline
Posts: 3
Joined: Feb 13, 2017

Python Scripting Support for Triggers?

I was trying to find the answer to this question but after hours of search still no luck, so thought I'd ask here...

In short, do we yet have support for scripting in Python to change the actions of a trigger? Specifically, to change the script code of an "Execute script" action?

Asking because I've been using the Homebridge-Indigo plugin to integrate Indigo with Apple HomeKit. I created triggers (action written in Python) for each device so that when its state changes, the trigger sends an http request to Homebridge which notifies HomeKit of the status change. Since I have lots of devices, I adapted a script found on the forum (couldn't remember where exactly it was) to batch create such triggers - obviously this includes changing the script code of these triggers, and since Python didn't support this function, it was done with help of AppleScript like this:

app.trigger_actions["Trigger Name"].action_steps[1].script_code.set("Python Script Here")

But recently I found this method stopped working - in event log it just says "Application can not handle this command". After finding that AppleScript support will be deprecated soon, I wonder if we already can do the same thing in Python?

Any help would be greatly appreciated.

Posted on
Fri Feb 09, 2018 9:56 am
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: Python Scripting Support for Triggers?

There are a few things you can do. The callback that you were using that failed was actually built for Homebridge Buddy and is in use now to notify HomeKit of updates. There's a new plugin and entire package being currently developed called HomeKit Bridge which will also do this. So, along these lines, you could either use HBB now or wait for HKB to get out of closed beta in a few weeks and you get that. You can still run HB-Indigo as the full HB server and run HBB too (in fact HBB was designed to manage HB-Indigo before it also added having an integrated server).

Other than that, no, you cannot modify scripts or really do much with triggers via code, but you could write a plugin that would subscribe to all device changes and then run the URL when one of those device changes are interesting enough for you to hit HB-Indigo with. That is essentially what is built into HBB and HKB.

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

Posted on
Fri Feb 09, 2018 10:06 am
jay (support) offline
Site Admin
User avatar
Posts: 18212
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Python Scripting Support for Triggers?

masterchief wrote:
In short, do we yet have support for scripting in Python to change the actions of a trigger? Specifically, to change the script code of an "Execute script" action?


Not until the 7.2 release at the earliest. No ETA yet, but it will happen sometime this year.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Fri Feb 09, 2018 2:32 pm
masterchief offline
Posts: 3
Joined: Feb 13, 2017

Re: Python Scripting Support for Triggers?

Colorado4Wheeler wrote:
There are a few things you can do. The callback that you were using that failed was actually built for Homebridge Buddy and is in use now to notify HomeKit of updates. There's a new plugin and entire package being currently developed called HomeKit Bridge which will also do this. So, along these lines, you could either use HBB now or wait for HKB to get out of closed beta in a few weeks and you get that. You can still run HB-Indigo as the full HB server and run HBB too (in fact HBB was designed to manage HB-Indigo before it also added having an integrated server).

Other than that, no, you cannot modify scripts or really do much with triggers via code, but you could write a plugin that would subscribe to all device changes and then run the URL when one of those device changes are interesting enough for you to hit HB-Indigo with. That is essentially what is built into HBB and HKB.


Colorado4Wheeler: thank you very much for the quick reply! You're so helpful as always. I remember last time when HBB became unavailable, and eventually I turned to using those triggers. It's indeed a pain to create and manage these triggers. Now if HBB can get it working, I'd 100% ditch the triggers. Let me give it a try and report back here :)

Posted on
Fri Feb 09, 2018 2:36 pm
masterchief offline
Posts: 3
Joined: Feb 13, 2017

Re: Python Scripting Support for Triggers?

jay (support) wrote:
masterchief wrote:
In short, do we yet have support for scripting in Python to change the actions of a trigger? Specifically, to change the script code of an "Execute script" action?


Not until the 7.2 release at the earliest. No ETA yet, but it will happen sometime this year.


Thank you Jay! I figured that might be the case. Python is hands down much better than AppleScript in Indigo, so really looking forward to seeing that feature being implemented! Hope that "sometime this year" is not as late as December XD

Posted on
Tue Dec 24, 2019 5:56 pm
mohaidar offline
User avatar
Posts: 3
Joined: Nov 30, 2019

Re: Python Scripting Support for Triggers?

Hi all,

Has any progress been made on this. Can we modify Actions through scripts?

Thanks,
Moe

Posted on
Fri Dec 27, 2019 11:55 am
matt (support) offline
Site Admin
User avatar
Posts: 21416
Joined: Jan 27, 2003
Location: Texas

Re: Python Scripting Support for Triggers?

mohaidar wrote:
Has any progress been made on this. Can we modify Actions through scripts?

Nothing that is ready to be released yet, but it remains a high priority.

Image

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 9 guests