(Solved) Any sample to set indigo variable in emb... python?

Posted on
Thu Feb 27, 2014 7:47 pm
hwitten offline
Posts: 627
Joined: Dec 26, 2007
Location: British Columbia

(Solved) Any sample to set indigo variable in emb... python?

I'm playing around with nest.py I found on github to perhaps change from nest plugin to an embedded script on a temporary basis so as to get rid of the errors the nest plugin is throwing.

I think I can do it but have not found any code sampling of setting an indigo variable from a python var.
Still looking. Any help to shorten the search is appreciated.

Heinz
Last edited by hwitten on Thu Feb 27, 2014 9:17 pm, edited 1 time in total.

Posted on
Thu Feb 27, 2014 8:40 pm
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Any sampling to set indigo variable in embedded python?

The Variable Examples in the scripting tutorial show setting variable values.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Thu Feb 27, 2014 8:44 pm
hwitten offline
Posts: 627
Joined: Dec 26, 2007
Location: British Columbia

Re: Any sampling to set indigo variable in embedded python?

Thanks Jay, I saw those but didn't see a python-->indigo example.
Maybe it's time for a break :)

No problem working with indigo vars, just the python --> indigo.
I'll go back and look again after a break.

Posted on
Thu Feb 27, 2014 9:10 pm
Bollar offline
Posts: 528
Joined: Aug 11, 2013

Re: Any sampling to set indigo variable in embedded python?

I'm not with Indigo, or I would just give you an example. Look at this thread: viewtopic.php?f=107&t=11386&hilit=Apis+noobs

I have several examples of parsing python variables into Indigo there.

Insteon / Z-Wave / Bryant Evolution Connex /Tesla / Roomba / Elk M1 / SiteSage / Enphase Enlighten / NOAA Alerts

Posted on
Thu Feb 27, 2014 9:16 pm
hwitten offline
Posts: 627
Joined: Dec 26, 2007
Location: British Columbia

Re: Any sampling to set indigo variable in embedded python?

Thank you Bollar. That'll do it.

Posted on
Thu Feb 27, 2014 9:21 pm
Bollar offline
Posts: 528
Joined: Aug 11, 2013

Re: (Solved) Any sample to set indigo variable in emb... pyt

You fix the Nest script and we'll call it even!

Insteon / Z-Wave / Bryant Evolution Connex /Tesla / Roomba / Elk M1 / SiteSage / Enphase Enlighten / NOAA Alerts

Posted on
Thu Feb 27, 2014 9:31 pm
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: (Solved) Any sample to set indigo variable in emb... pyt

@hwitten - I'm not sure what you were looking for - can you post an example of what you were trying to do? Maybe we should add it to the tutorial...

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Thu Feb 27, 2014 9:39 pm
hwitten offline
Posts: 627
Joined: Dec 26, 2007
Location: British Columbia

Re: (Solved) Any sample to set indigo variable in emb... pyt

It turned out really simple and I really should've been able to figure it out. Duh. Of course always easy once the light gets turned on :)

Code: Select all
indigo.variable.updateValue(1920763080, value=str(pythonVar))

Untested :)

Posted on
Fri Feb 28, 2014 10:02 am
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: (Solved) Any sample to set indigo variable in emb... pyt

Oh - I get it. Sorry, I just made the assumption that showing a python string in the example was good enough. Note - if the value of the python variable is already a string you don't need to cast it (put it inside the str() method).

Code: Select all
indigo.variable.updateValue(1920763080, value=pythonVar)


Also, you might want to use unicode() rather than str() since it'll work with any extended characters as well. So:

Code: Select all
myPythonString = u"éçø"
indigo.variable.updateValue(1920763080, value=unicode(myPythonString))


The above example is contrived since you know that myPythonString is already a unicode string - but if you're getting the data from somewhere else and it might contain unicode characters then it's safer to use unicode(myPythonString) since str(myPythonString) will throw an error.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Fri Feb 28, 2014 10:09 am
hwitten offline
Posts: 627
Joined: Dec 26, 2007
Location: British Columbia

Re: (Solved) Any sample to set indigo variable in emb... pyt

Thanks very much Jay.
Guess by hook or by crook I'm going to have to learn more Python :)

Going to give it another day on the nest plugin directly but might have to resort to my fallback idea.
Hate unsolved riddles though :)

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 5 guests