Can I pass a variable to a linked python script?

Posted on
Sun Dec 18, 2016 2:25 pm
ryanbuckner offline
Posts: 1080
Joined: Oct 08, 2011
Location: Northern Virginia

Re: Can I pass a variable to a linked python script?

I'm gonna need a hint here:

This line :
Code: Select all
indigo.server.log(u"Executing Light Flash...")


Throws this error:

Code: Select all
Traceback (most recent call last):
  File "./bmwposthorn.py", line 21, in <module>
    indigo.server.log(u"Executing Light Flash...")
NameError: name 'indigo' is not defined

Posted on
Sun Dec 18, 2016 2:44 pm
DaveL17 offline
User avatar
Posts: 6757
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Can I pass a variable to a linked python script?

Ryan - you don't need to import Indigo into your scripts. Indigo is loaded automatically as a part of the host process.

Any of your scripts that you want to import into other scripts should be placed in the relevant site-packages folder for the version of Python you're using.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sun Dec 18, 2016 3:01 pm
ryanbuckner offline
Posts: 1080
Joined: Oct 08, 2011
Location: Northern Virginia

Re: Can I pass a variable to a linked python script?

Thanks. It's working. The error was only throw when executing from terminal.

Posted on
Sun Dec 18, 2016 5:03 pm
ryanbuckner offline
Posts: 1080
Joined: Oct 08, 2011
Location: Northern Virginia

Re: Can I pass a variable to a linked python script?

jay (support) wrote:
Actually, you'd execute the script in your control page action so it wouldn't be dependent on the variable change. Make the first action in your page element change the variable, make the second action execute the script (you may have to add a 1 second delay just to make sure the variable change happens before the script runs). If you have nothing else that's changing the variable and needing the automatic reaction then just delete the variable change trigger.

So any time you tap the page element, it changes the variable (regardless of whether it needs to or not) and then runs the script, which does the right thing.


This worked.

I now have 4 buttons on my control page that change a variable and then execute 1 python script that reads in the variable to determine the command to send to the BMW API. I used a 2 second delay on the call to the .py to make sure the variable is changed before trying to read it.

Thanks Jay!

Posted on
Tue Dec 20, 2016 11:56 pm
bkmar1192 offline
Posts: 274
Joined: Sep 12, 2015

Re: Can I pass a variable to a linked python script?

Another option I have done is created a trigger that fires on variable change and runs my script. My script does the following 1) deactivates the trigger 2) does the things 3) sets the variable to null 4) deactivates the script.

The button on my control page just sets the variable value which kicks off the trigger.

You have to deactivate and then deactivate or it goes into endless loop (learned that the hard way). The benefit to this is I know if the script finished or not. You could even put an error message in the variable if it didn't run correctly.


Sent from my iPhone using Tapatalk

Who is online

Users browsing this forum: No registered users and 8 guests