Comparing outside temps and updating variables in Python

Posted on
Tue Oct 29, 2019 2:48 pm
Sofabutt offline
Posts: 11
Joined: Feb 12, 2018

Comparing outside temps and updating variables in Python

I am in the process of updating my Indigo serv er scripts to Python and have been working on this particular script all day.

I want the script to update the yearlyHighTemp and yearlyLowTemp as the temperature outsides rises above or below the current hig and low. This is what I have so far:
Code: Select all
nowTemp = indigo.variables[1403030637].value
yearHigh = indigo.variables[762466133].value
yearLow = indigo.variables[128906629].value

if nowTemp > yearHigh
    indigo.variable.updateValue(762466133, value=float(nowTemp.value))




I get the following error when I try it:
Script Error embedded script: invalid syntax
Script Error around line 5 - "if nowTemp > yearHigh"

Can someone please help?

Thanks in advance.

Posted on
Tue Oct 29, 2019 2:57 pm
FlyingDiver offline
User avatar
Posts: 7217
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Comparing outside temps and updating variables in Python

.value returns a string. You need to use .getValue(float).

Also, your if line needs a ":" at the end. That's what's actually causing the syntax error.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Tue Oct 29, 2019 2:59 pm
FlyingDiver offline
User avatar
Posts: 7217
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Comparing outside temps and updating variables in Python

Code: Select all
nowTemp = indigo.variables[1403030637].getValue(float)
yearHigh = indigo.variables[762466133].getValue(float)
yearLow = indigo.variables[128906629].getValue(float)

if nowTemp > yearHigh:
    indigo.variable.updateValue(762466133, value=nowTemp)


joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Tue Oct 29, 2019 3:37 pm
Sofabutt offline
Posts: 11
Joined: Feb 12, 2018

Re: Comparing outside temps and updating variables in Python

Thanks for your help. That fix eliminated an error that kept popping up every few minutes as the temp outsides soars above 28 degrees F.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 4 guests

cron