Somewhere between "how to write a script" and "advanced"

Posted on
Fri Jul 17, 2020 9:48 am
Different Computers offline
User avatar
Posts: 1979
Joined: Jan 02, 2016
Location: East Coast

Somewhere between "how to write a script" and "advanced"

I've had Indigo trigger external shell scripts in the past, so I know the very basics.

But I'm getting tired of a couple of my embedded Python camera control scripts timing out, and want to make them external scripts.

All my searching either finds Advanced Topics, or stuff about converting AppleScripts.

Is there something to this besides saving an external text file with the script? I imagine there's some up front stuff required, like a shell script requires, so I think I probably need to add something besides just the script to the file.

Does Indigo need each external script to declare the path to Python? Tutorials like https://www.pythonforbeginners.com/deve ... on-scripts aren't really addressing what I need to know.

Apologies if my search-fu isn't up to snuff, but searching here didn't result in something that addresses my particular level of cluelessness. Like down to which file extension to use: .py or .pyw?

SmartThings refugee, so happy to be on Indigo. 10.13.6 on an i5 MBP w/Harmony Hub, Hue, DomoPad, Dynamic URL, Device Extensions, HomeKit Bridge, MatplotLib, Plex, uniFAP, Wunderground, Nanoleaf, LED Simple Effects, Airfoil Pro, Grafana.

Posted on
Fri Jul 17, 2020 10:16 am
Different Computers offline
User avatar
Posts: 1979
Joined: Jan 02, 2016
Location: East Coast

Re: Somewhere between "how to write a script" and "advanced"

So, even though my script is error-ing like crazy, those errors are because the camera the script targets is acting wonky.

The conversion seems as simple as:

1. Copy the embedded script
2. Paste into your fave text editor,
3. Save on the Indigo Box with .py.
4. Point the Action group (or whatever) that had the embedded script in it at the file.

SmartThings refugee, so happy to be on Indigo. 10.13.6 on an i5 MBP w/Harmony Hub, Hue, DomoPad, Dynamic URL, Device Extensions, HomeKit Bridge, MatplotLib, Plex, uniFAP, Wunderground, Nanoleaf, LED Simple Effects, Airfoil Pro, Grafana.

Posted on
Fri Jul 17, 2020 12:10 pm
jay (support) offline
Site Admin
User avatar
Posts: 16307
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Somewhere between "how to write a script" and "advanced"

Different Computers wrote:
So, even though my script is error-ing like crazy, those errors are because the camera the script targets is acting wonky.

The conversion seems as simple as:

1. Copy the embedded script
2. Paste into your fave text editor,
3. Save on the Indigo Box with .py.
4. Point the Action group (or whatever) that had the embedded script in it at the file.


That's pretty much it. Be sure to use a text editor that doesn't save as rich text (TextEdit does by default). External scripts like that are run in an Indigo Host process which will automatically include the indigo module. Any other imports that your script needs should be specified in the script already so the copy/paste should include them.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sun Jul 19, 2020 6:41 pm
Different Computers offline
User avatar
Posts: 1979
Joined: Jan 02, 2016
Location: East Coast

Re: Somewhere between "how to write a script" and "advanced"

Thanks!

It was way easier than I expected. Easier than a bash script!

SmartThings refugee, so happy to be on Indigo. 10.13.6 on an i5 MBP w/Harmony Hub, Hue, DomoPad, Dynamic URL, Device Extensions, HomeKit Bridge, MatplotLib, Plex, uniFAP, Wunderground, Nanoleaf, LED Simple Effects, Airfoil Pro, Grafana.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 0 guests