Controlling Indigo from Command Line (or .py files)

Posted on
Wed Jun 01, 2016 12:15 pm
FlyingDiver offline
Posts: 2990
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Controlling Indigo from Command Line (or .py files)

I'm not sure what you find inelegant about using an Action Group to accomplish what you're doing. Other than the fact it appears you're doing most of your system control in Python scripts that are not, in fact, part of Indigo. They're just started up by Indigo when needed. If it was me, I'd be trying to figure out how to make the system more integrated with Indigo, not less. But that's just me. In any case, Jay already pointed out the solution to the executable path issue you were having.

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

Posted on
Fri Jun 03, 2016 8:22 am
RedYuriPrime offline
Posts: 43
Joined: Oct 14, 2014
Location: Oxford

Re: Controlling Indigo from Command Line (or .py files)

OK, making some progress.
Having correctly con figured .bash_profile and .bashrc to set up the alias, I can no run in Terminal a .py file under the IPH. As an example:

Last login: Fri Jun 3 14:49:38 on ttys000
Geoffs-Mac-mini:~ geoff$ indigohost -x /Users/geoff/Documents/Indigo/ActivePython/TestEasyDAC.py
Geoffs-Mac-mini:~ geoff$


However, putting the same line:
indigohost -x /Users/geoff/Documents/Indigo/ActivePython/TestEasyDAC.py
into a .py file and then running this within Indigo gives the following error:-

Script Error Core.py: global name 'indigohost' is not defined
Script Error Exception Traceback (most recent call shown last):

Core.py, line 68, at top level
NameError: global name 'indigohost' is not defined

So I must still be missing something.

Z-wave system with 80+ devices, Indigo7 on a dedicated MacMini
Controlling lighting, heating, hotwater, security; but still a lot to learn ... :shock:

Posted on
Fri Jun 03, 2016 9:40 am
FlyingDiver offline
Posts: 2990
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Controlling Indigo from Command Line (or .py files)

That's because the aliases you set up in your .bash_profile and .bashrc files are not available to scripts running from Indigo.

Just put the complete path name in your script as:

Code: Select all
/Library/Application\ Support/Perceptive\ Automation/Indigo\ 6/IndigoPluginHost.app/Contents/MacOS/indigohost -x /Users/geoff/Documents/Indigo/ActivePython/TestEasyDAC.py

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

Posted on
Mon Jun 06, 2016 2:19 am
RedYuriPrime offline
Posts: 43
Joined: Oct 14, 2014
Location: Oxford

Re: Controlling Indigo from Command Line (or .py files)

Thanks Joe. However have tried the format you and Jay provided, and unfortunately it doesn't work, giving:

Script Error Core.py: invalid syntax
Script Error around line 83 - "/Library/Application\ Support/Perceptive\ Automation/Indigo\ 6/IndigoPluginHost.app/Contents/MacOS/IndigoPluginHost -x /Users/geoff/Documents/Indigo/ActivePython/TestEasyDAC.py"

Have resorted to the following; it does seem to work, although I do need to do further testing:
###
import subprocess

def rRun(module):
host ="/Library/Application Support/Perceptive Automation/Indigo 6/IndigoPluginHost.app/Contents/MacOS/IndigoPluginHost"
switch ="-x"
modulePath="/Users/geoff/Documents/Indigo/ActivePython/" + module
subprocess.Popen([host,switch,modulePath])

rRun("TestEasyDAC.py")
###

Will update in a few days to confirm if there are any unexpected side effects.

Regards,
Geoff

Z-wave system with 80+ devices, Indigo7 on a dedicated MacMini
Controlling lighting, heating, hotwater, security; but still a lot to learn ... :shock:

Posted on
Fri Jun 17, 2016 2:41 am
RedYuriPrime offline
Posts: 43
Joined: Oct 14, 2014
Location: Oxford

Re: Controlling Indigo from Command Line (or .py files)

OK, just an update to say that the above solution is stable and does the job. :D

Z-wave system with 80+ devices, Indigo7 on a dedicated MacMini
Controlling lighting, heating, hotwater, security; but still a lot to learn ... :shock:

Who is online

Users browsing this forum: No registered users and 1 guest