send variables to 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

Posted on
Sat Mar 09, 2013 11:15 am
HA1 offline
Posts: 71
Joined: Mar 15, 2012

send variables to python script

Is there any way, when executing a python script, that I can access some variable that's sent in via a REST call that executes that action group?

For example, I want to be able to execute
http://indigoserver/actions/myaction?_m ... =somevalue

And then somewhere in a python script for action group "myaction" I want to be able to access that variable's ("variable1") value in my python script. I presume I have access to Indigo variables in python scripts? Even if I do, I'm still not sure how to set an Indigo variable as part of an action group via a REST API parameter.

Thanks in advance for any advice.

Posted on
Sat Mar 09, 2013 12:59 pm
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: send variables to python script

You can do it, but it will require more than a single RESTful URL call. You cannot both set an Indigo variable value and execute an Action Group in a single call.

Here is the RESTful call to change an Indigo variable value:

Code: Select all
http://127.0.0.1:8176/variables/some_var_name?_method=put&value=somevalue

And here is accessing that value from an Indigo python script:

Code: Select all
var = indigo.variables["some_var_name"]   # Instead of a string name try to use the numerical ID for the var
indigo.server.log("value is: " + str(var.value))

Image

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests