send variables to python script

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
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
HA1
Posts: 71
Joined: Thu Mar 15, 2012 9:43 pm

send variables to python script

Post by HA1 »

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.
User avatar
matt (support)
Site Admin
Posts: 21542
Joined: Mon Jan 27, 2003 1:17 pm
Location: Texas
Contact:

Re: send variables to python script

Post by matt (support) »

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
Locked

Return to “Extending Indigo with Plugins and Python”