Script that compare temperature reading from two sensors

Posted on
Wed Nov 04, 2020 3:19 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Script that compare temperature reading from two sensors

As I said, that script needs to be the Action of the schedule, not the Condition.

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

Posted on
Wed Nov 04, 2020 3:29 pm
Eagleye offline
Posts: 82
Joined: Jan 14, 2019

Re: Script that compare temperature reading from two sensors

Ok, I have never done this below.

So just confirming, I would need to do the following for the schedule to work correctly?:
Attachments
Screen Shot 2020-11-05 at 8.27.01 am.png
Screen Shot 2020-11-05 at 8.27.01 am.png (164.33 KiB) Viewed 1947 times
Screen Shot 2020-11-05 at 8.27.37 am.png
Screen Shot 2020-11-05 at 8.27.37 am.png (171.95 KiB) Viewed 1947 times

Posted on
Wed Nov 04, 2020 3:30 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Script that compare temperature reading from two sensors

On the condition tab, delete the script and select the "Always" option.

Other than that, looks right.

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

Posted on
Wed Nov 04, 2020 3:33 pm
Eagleye offline
Posts: 82
Joined: Jan 14, 2019

Re: Script that compare temperature reading from two sensors

Perfect :wink: Thank you for your help with this, I learned something new. I just need to learn more about script writing.

Posted on
Wed Nov 04, 2020 3:34 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Script that compare temperature reading from two sensors

There are lots of good Python beginner tutorials on the net.

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

Posted on
Wed Nov 04, 2020 3:37 pm
Eagleye offline
Posts: 82
Joined: Jan 14, 2019

Re: Script that compare temperature reading from two sensors

Thanks Flyingdiver, I will check it out.

Posted on
Fri Dec 02, 2022 3:49 pm
Eagleye offline
Posts: 82
Joined: Jan 14, 2019

Re: Script that compare temperature reading from two sensors

I have created the following script to change a temperature variable, but for some reason I'm getting a "name 'Unicode"is not defined". As my script writing is limited, can someone please help me to correct the script error.

Code: Select all
outside_temp = indigo.devices[76913492].states['sensorValue']
inside_temp = indigo.devices[181198247].states['sensorValue']

indigo.variable.updateValue(1281976055, value=unicode(outside_temp <= inside_temp))

Posted on
Fri Dec 02, 2022 4:45 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Script that compare temperature reading from two sensors

unicode is invalid in Python 3 (which is what's used for scripts in Indigo 2022.1 and later). Change it to str (all strings are unicode in Python 3):

Code: Select all
outside_temp = indigo.devices[76913492].states['sensorValue']
inside_temp = indigo.devices[181198247].states['sensorValue']

indigo.variable.updateValue(1281976055, value=str(outside_temp <= inside_temp))

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Fri Dec 02, 2022 8:48 pm
Eagleye offline
Posts: 82
Joined: Jan 14, 2019

Re: Script that compare temperature reading from two sensors

Thanks Jay, appreciate your prompt response.

After further search on the internet, I came up with the same solution.

John

Who is online

Users browsing this forum: No registered users and 3 guests