Launch indigohost from within python 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
Launch indigohost from within python script
I'm just a beginner with python and am not up to creating a plugin just yet. I would like to access Indigo from within an existing python script I have so I can write to variables and turn devices on and off. Is there an easy way to launch indigohost and execute a command?
- matt (support)
- Site Admin
- Posts: 21542
- Joined: Mon Jan 27, 2003 1:17 pm
- Location: Texas
- Contact:
Re: Launch indigohost from within python script
We are in the process of adding an option to the Execute Action UI so that you can execute an Indigo python script (embedded or via a file) in addition to AppleScript. Once that is done it will be easy, but until then it is only possible via a plugin or the interactive shell.
Re: Launch indigohost from within python script
Don't think that would work for this particular application. I have an always running server app that I would never launch from within Indigo - unless I went the plugin route. Guess I will have to investigate plugins. I have scripts that I use for the Russound RNET that I've been playing with - I will have a pretty neat control page for it soon enough.
- matt (support)
- Site Admin
- Posts: 21542
- Joined: Mon Jan 27, 2003 1:17 pm
- Location: Texas
- Contact:
Re: Launch indigohost from within python script
A native plugin would be the optimal approach, but there might be some other approaches as well eventually. Let me think about it for a bit.
Re: Launch indigohost from within python script
Have you looked at the RESTful API? In Indigo 4, I used it primarily to update variables, but it's possible to turn devices on and off too. Here's some code I used to update variables:nlagaros wrote:I'm just a beginner with python and am not up to creating a plugin just yet. I would like to access Indigo from within an existing python script I have so I can write to variables and turn devices on and off. Is there an easy way to launch indigohost and execute a command?
Code: Select all
def setVariable(host,port,root,variable,value):
conn = httplib.HTTPConnection(host,port)
params = urllib.urlencode({'value':value})
headers = {"Content-type": "application/x-www-form-urlencoded"}
url=root+"/variables/"+variable
conn.request("PUT",url,params,headers)
response = conn.getresponse()
if (response.status==303):
conn.close
return response
print "Problem setting "+variable+" to "+str(value)+": "+str(response.status)+" "+response.reason
print response.read()
conn.close()
return response
- matt (support)
- Site Admin
- Posts: 21542
- Joined: Mon Jan 27, 2003 1:17 pm
- Location: Texas
- Contact:
Re: Launch indigohost from within python script
Oh yeah, I had forgotten about that. Great suggestion I think for what he is looking for.
Re: Launch indigohost from within python script
That did the trick! Thanks!
-
bschollnick2
- Posts: 1355
- Joined: Sun Oct 17, 2004 8:21 am
- Location: Rochester, Ny
- Contact:
Re: Launch indigohost from within python script
Jamus,jamus wrote:Have you looked at the RESTful API? In Indigo 4, I used it primarily to update variables, but it's possible to turn devices on and off too. Here's some code I used to update variables:nlagaros wrote:I'm just a beginner with python and am not up to creating a plugin just yet. I would like to access Indigo from within an existing python script I have so I can write to variables and turn devices on and off. Is there an easy way to launch indigohost and execute a command?
Don't forget, I have a unofficial Restful wrapper for Indigo already constructed in Python.
Restful Link
The main benefit, is that I've already done much of the work, and it's a bit more abstracted... And completely reusable, as a standalone module.
------
My Plugins for Indigo (v4, v5, and v6) - http://bit.ly/U8XxPG
Security Script for v4 - http://bit.ly/QTgclf
for v5 - http://bit.ly/T6WBKu
Support Forum(s) - http://www.perceptiveautomation.com/userforum/viewforum.php?f=33
My Plugins for Indigo (v4, v5, and v6) - http://bit.ly/U8XxPG
Security Script for v4 - http://bit.ly/QTgclf
for v5 - http://bit.ly/T6WBKu
Support Forum(s) - http://www.perceptiveautomation.com/userforum/viewforum.php?f=33
Re: Launch indigohost from within python script
Thanks for all the help. I shelled out to curl initially, but this wrapper looks perfect.
-
bschollnick2
- Posts: 1355
- Joined: Sun Oct 17, 2004 8:21 am
- Location: Rochester, Ny
- Contact:
Re: Launch indigohost from within python script
Feel free to give me feedback, it was designed with Indigo 4 in mind, but v5 features can be added as well...nlagaros wrote:Thanks for all the help. I shelled out to curl initially, but this wrapper looks perfect.
And feel free to send suggestions for code, etc...
------
My Plugins for Indigo (v4, v5, and v6) - http://bit.ly/U8XxPG
Security Script for v4 - http://bit.ly/QTgclf
for v5 - http://bit.ly/T6WBKu
Support Forum(s) - http://www.perceptiveautomation.com/userforum/viewforum.php?f=33
My Plugins for Indigo (v4, v5, and v6) - http://bit.ly/U8XxPG
Security Script for v4 - http://bit.ly/QTgclf
for v5 - http://bit.ly/T6WBKu
Support Forum(s) - http://www.perceptiveautomation.com/userforum/viewforum.php?f=33
Re: Launch indigohost from within python script
Yep, I completely forgot, which I feel terrible about because we had a discussion on this forum about the Python API a while back.bschollnick2 wrote:Jamus,
Don't forget, I have a unofficial Restful wrapper for Indigo already constructed in Python.
Restful Link
The main benefit, is that I've already done much of the work, and it's a bit more abstracted... And completely reusable, as a standalone module.
I think there's still use for your API in 5.0. I get the impression that remote access via python, if even possible, would require an indigo installation to get the necessary modules. I haven't had a chance to read through all the documentation, so I could be mistaken.
-
bschollnick2
- Posts: 1355
- Joined: Sun Oct 17, 2004 8:21 am
- Location: Rochester, Ny
- Contact:
Re: Launch indigohost from within python script
Not with the Restful API Wrapper. It's completely independent of Indigo.. It's effectively just using the Python equivalent of CURL to communicate with Indigo.jamus wrote:Yep, I completely forgot, which I feel terrible about because we had a discussion on this forum about the Python API a while back.bschollnick2 wrote:Jamus,
Don't forget, I have a unofficial Restful wrapper for Indigo already constructed in Python.
Restful Link
The main benefit, is that I've already done much of the work, and it's a bit more abstracted... And completely reusable, as a standalone module.
I think there's still use for your API in 5.0. I get the impression that remote access via python, if even possible, would require an indigo installation to get the necessary modules. I haven't had a chance to read through all the documentation, so I could be mistaken.
- Benjamin
------
My Plugins for Indigo (v4, v5, and v6) - http://bit.ly/U8XxPG
Security Script for v4 - http://bit.ly/QTgclf
for v5 - http://bit.ly/T6WBKu
Support Forum(s) - http://www.perceptiveautomation.com/userforum/viewforum.php?f=33
My Plugins for Indigo (v4, v5, and v6) - http://bit.ly/U8XxPG
Security Script for v4 - http://bit.ly/QTgclf
for v5 - http://bit.ly/T6WBKu
Support Forum(s) - http://www.perceptiveautomation.com/userforum/viewforum.php?f=33
Re: Launch indigohost from within python script
I meant that remote access with the official Python API may not be possible or require an indigo installation.bschollnick2 wrote:Not with the Restful API Wrapper. It's completely independent of Indigo.. It's effectively just using the Python equivalent of CURL to communicate with Indigo.jamus wrote: I think there's still use for your API in 5.0. I get the impression that remote access via python, if even possible, would require an indigo installation to get the necessary modules. I haven't had a chance to read through all the documentation, so I could be mistaken.
- Benjamin
