Python from other apps to control Indigo

Posted on
Mon Oct 09, 2017 12:00 pm
nev offline
Posts: 48
Joined: Aug 19, 2015

Python from other apps to control Indigo

Hi All,
I'm trying to convert all my applescripts to python and must be missing something. I am currently working on my HamBridge server app which used AppleScript to tell Indigo to change variable values based on http calls it got from various APIs. All I'm trying to do it have it update a variable value, but i get is ab error "Name 'Indigo' is not defined"

Code: Select all
#! /usr/bin/env python
import commands,os,random,sys

myVar = indigo.variables["home"]
indigo.variable.updateValue(myVar,false)
myVar.refreshFromServer()


How do i get this to work?

Posted on
Mon Oct 09, 2017 12:13 pm
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: Python from other apps to control Indigo

The "indigo.***" APIs are only available from a special Indigo based python environment. Indigo plugins and Indigo actions that execute python scripts provide that environment automatically (we call it the indigohost or IndigoPluginHost/IPH). If you need to initiate a python script from outside Indigo you can use the indigohost. See this section of the plugin tutorial for some details.

Once you've defined the indigohost alias, which just makes calling it simpler, you can execute python code either embedded or using the indigohost to specify a python file for execution (with the indigo.*** APIs available).

Image

Posted on
Fri Dec 01, 2017 2:19 pm
nev offline
Posts: 48
Joined: Aug 19, 2015

Re: Python from other apps to control Indigo

This works well for me to control variables in indigo from other applications.
curl -u <username>:<password> --digest -X PUT -d value=false http://serverIP:8176/variables/<variable_name>

How do I use this type of method to trigger an Action Group?

Thanks!

Posted on
Fri Dec 01, 2017 2:29 pm
roussell offline
User avatar
Posts: 1108
Joined: Aug 18, 2008
Location: Alabama

Re: Python from other apps to control Indigo

I don’t believe the guys have implemented action groups through REST yet. What I do is create a virtual device, and have that virtual device trigger an action group. You can then switch the virtual device using a variation of your curl statement. You could also change an Indigo variable, then have a trigger watching that variable and fire off the action group.

Terry


Sent from my iPhone using Tapatalk

Posted on
Fri Dec 01, 2017 3:43 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Python from other apps to control Indigo

nev wrote:
How do I use this type of method to trigger an Action Group?


Code: Select all
curl -u <username>:<password> --digest -X EXECUTE http://127.0.0.1:8176/actions/party%20scene

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Fri Dec 01, 2017 3:44 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Python from other apps to control Indigo

jay (support) wrote:
nev wrote:
How do I use this type of method to trigger an Action Group?


Code: Select all
curl -u <username>:<password> --digest -X EXECUTE http://127.0.0.1:8176/actions/party%20scene


Check out the RESTful API docs for examples of everything it can do.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Fri Dec 01, 2017 4:24 pm
roussell offline
User avatar
Posts: 1108
Joined: Aug 18, 2008
Location: Alabama

Re: Python from other apps to control Indigo

Cool!! Guess I’ve got some updates to do too!

Terry


Sent from my iPhone using Tapatalk

Posted on
Fri Dec 01, 2017 7:01 pm
nev offline
Posts: 48
Joined: Aug 19, 2015

Re: Python from other apps to control Indigo

Perfect!!!! Thanks so much.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 10 guests