Calling an atached 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
User avatar
bob
Posts: 500
Joined: Wed Jun 14, 2006 7:55 am

Calling an atached Python script

Post by bob »

Could you give me an example of calling a Python script in the Attachments folder from an embedded script?

Using an Applescript as an example you could have an embedded script like so;

Code: Select all

turnOnLight("livingroomLamp")
and then the script in the Attachements folder would be;

Code: Select all

on turnOnLight(someLight)
turn on device someLight
thanks!
User avatar
jay (support)
Site Admin
Posts: 19232
Joined: Wed Mar 19, 2008 11:52 am
Location: Austin, Texas
Contact:

Re: Calling an atached Python script

Post by jay (support) »

Jay (Indigo Support)
Twitter | Facebook | LinkedIn
User avatar
bob
Posts: 500
Joined: Wed Jun 14, 2006 7:55 am

Re: Calling an attached Python script

Post by bob »

Jay,

Thanks for your reply.

I did read it and because I find it difficult to understand I asked for an example. I put this function in site-packages and tried to call it using tempAdjust(); from an embedded script but I get an error "embedded script: global name 'tempAdjust' is not defined.

Code: Select all

def tempAdjust():

    #python script to increase the furnace ON/OFF temperatures

    #get variable "furnaceONtemp_"
    furnaceONtemp = indigo.variables["furnaceONtemp_"]
    furnaceONtemp = furnaceONtemp.getValue(float)

    #get variable "furnaceOFFtemp_"
    furnaceOFFtemp = indigo.variables["furnaceOFFtemp_"]
    furnaceOFFtemp = furnaceOFFtemp .getValue(float)
    
    indigo.variable.updateValue("furnaceONtemp_", str(furnaceONtemp + .25))
    indigo.variable.updateValue("furnaceOFFtemp_", str(furnaceOFFtemp + .25))

User avatar
matt (support)
Site Admin
Posts: 21542
Joined: Mon Jan 27, 2003 1:17 pm
Location: Texas
Contact:

Re: Calling an attached Python script

Post by matt (support) »

Did you import your attachment in the calling script? See the example Jay linked to. There is an example that shows both the attachment side and the calling side. Try it and get that working, then modify it with your function.
Image
Locked

Return to “Extending Indigo with Plugins and Python”