Script that compare temperature reading from two sensors

Posted on
Thu Oct 24, 2019 9:30 pm
Eagleye offline
Posts: 83
Joined: Jan 14, 2019

Re: Script that compare temperature reading from two sensors

Thank you, that makes sense, I'll see how this goes.

Posted on
Fri Oct 25, 2019 6:00 am
DaveL17 offline
User avatar
Posts: 6753
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Script that compare temperature reading from two sensors

FlyingDiver wrote:
On the other hand, the sample script posted above needs to have ONE of the last two lines uncommented to work.

Yes, sorry if that wasn't clear.

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

[My Plugins] - [My Forums]

Posted on
Tue Nov 03, 2020 5:16 pm
Eagleye offline
Posts: 83
Joined: Jan 14, 2019

Re: Script that compare temperature reading from two sensors

Further to this post, I now want to create a variable that either becomes TRUE when the outside temperature becomes less than the inside temperature, and FALSE when the opposite applies, using an internal & external z-wave temperature sensor.

How would the script be written to create these to scenarios. I tried the below, but it does not seem to work.

True
outside_temp = indigo.devices[209400252].states['sensorValue']
inside_temp = indigo.devices[1450104654].states['sensorValue']

outside_temp < inside_temp

False
outside_temp = indigo.devices[209400252].states['sensorValue']
inside_temp = indigo.devices[1450104654].states['sensorValue']

outside_temp > inside_temp

Posted on
Tue Nov 03, 2020 5:27 pm
FlyingDiver offline
User avatar
Posts: 7217
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Script that compare temperature reading from two sensors

What doesn't work? How are you using that comparison operation?

Actual code and output would be useful.

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

Posted on
Tue Nov 03, 2020 8:43 pm
Eagleye offline
Posts: 83
Joined: Jan 14, 2019

Re: Script that compare temperature reading from two sensors

I created two schedules that checks thew above conditions every 10mins., and then modifies accordingly the status (True/false) of a created "Outdoor_Temp_less_than_Inside Temp" variable.

Posted on
Tue Nov 03, 2020 8:45 pm
FlyingDiver offline
User avatar
Posts: 7217
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Script that compare temperature reading from two sensors

Try doing the comparison directly from the device states and not using intermediate variables.

Or am I misunderstanding? Why two schedules?

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

Posted on
Tue Nov 03, 2020 8:48 pm
Eagleye offline
Posts: 83
Joined: Jan 14, 2019

Re: Script that compare temperature reading from two sensors

One schedule to to change the variable to True & another to change it to False.
Attachments
Screen Shot 2020-11-04 at 1.45.22 pm.png
Screen Shot 2020-11-04 at 1.45.22 pm.png (142.55 KiB) Viewed 2510 times
Screen Shot 2020-11-04 at 1.45.22 pm.png
Screen Shot 2020-11-04 at 1.45.22 pm.png (142.55 KiB) Viewed 2510 times
Screen Shot 2020-11-04 at 1.45.22 pm.png
Screen Shot 2020-11-04 at 1.45.22 pm.png (142.55 KiB) Viewed 2510 times

Posted on
Tue Nov 03, 2020 8:51 pm
FlyingDiver offline
User avatar
Posts: 7217
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Script that compare temperature reading from two sensors

You posted the same screen shot three times, as best I can tell.

Post shots of the conditions that are driving those actions.

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

Posted on
Tue Nov 03, 2020 8:59 pm
Eagleye offline
Posts: 83
Joined: Jan 14, 2019

Re: Script that compare temperature reading from two sensors

As the inside & outside temperatures are constant variables, I don't quite understand how I can use the device states.
I find that when I'm adding a condition to either a schedule or trigger, I can either use the "Condition match rules" or "python script", but not both and my script writing skills are limited at best.

As I have other conditions I would like to apply, I though by creating a variable that compare the state of the two temperature values, I could incorporate this into my "Conditions match rules".

Posted on
Tue Nov 03, 2020 9:04 pm
FlyingDiver offline
User avatar
Posts: 7217
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Script that compare temperature reading from two sensors

The problem I'm having is that I can't follow the complete sequence of events your logic is based on. You show a couple of lines of code getting the inside and outside temperatures, but where are you storing those? And you haven't shown how you're actually doing the comparison. There's some code in the thread from last week, but I don't know if that's what you're actually using.

If you're doing any of this in a Python script, then you should just do all of it there.

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

Posted on
Tue Nov 03, 2020 9:07 pm
Eagleye offline
Posts: 83
Joined: Jan 14, 2019

Re: Script that compare temperature reading from two sensors

Please see revised shots below
Attachments
Screen Shot 2020-11-04 at 2.02.09 pm.png
Screen Shot 2020-11-04 at 2.02.09 pm.png (200.01 KiB) Viewed 2496 times
Screen Shot 2020-11-04 at 2.02.33 pm.png
Screen Shot 2020-11-04 at 2.02.33 pm.png (144.81 KiB) Viewed 2496 times
Screen Shot 2020-11-04 at 1.44.47 pm.png
Screen Shot 2020-11-04 at 1.44.47 pm.png (188.89 KiB) Viewed 2496 times
Screen Shot 2020-11-04 at 1.45.08 pm.png
Screen Shot 2020-11-04 at 1.45.08 pm.png (165.35 KiB) Viewed 2496 times
Screen Shot 2020-11-04 at 1.45.22 pm.png
Screen Shot 2020-11-04 at 1.45.22 pm.png (142.55 KiB) Viewed 2496 times

Posted on
Tue Nov 03, 2020 9:14 pm
FlyingDiver offline
User avatar
Posts: 7217
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Script that compare temperature reading from two sensors

Ok, I see what's going on. You're making this much harder than it has to be. You need one schedule that just runs a script action that runs the following script (not tested). No conditions, no other actions - the script itself sets the variable. Change the ID number in the last line to that of your "outside_temp_less_than_inside_temp" variable.

Code: Select all
outside_temp = indigo.devices[209400252].states['sensorValue']
inside_temp = indigo.devices[1450104654].states['sensorValue']

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


The real problem in what you have is the last line of the condition script is:
Code: Select all
outside_temp < inside_temp


When it should be
Code: Select all
return (outside_temp < inside_temp)


But you really don't want to do that because then you need two schedules.

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

Posted on
Wed Nov 04, 2020 12:34 am
Eagleye offline
Posts: 83
Joined: Jan 14, 2019

Re: Script that compare temperature reading from two sensors

Thank you for your assistance with this, however I get an error message when using your script suggestion below (See attached screenshot).
Attachments
Screen Shot 2020-11-04 at 5.32.44 pm.png
Screen Shot 2020-11-04 at 5.32.44 pm.png (202.69 KiB) Viewed 2458 times

Posted on
Wed Nov 04, 2020 1:11 am
FlyingDiver offline
User avatar
Posts: 7217
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Script that compare temperature reading from two sensors

I said to use the variable’s ID number. If you use the name, you need to use quotation marks.


Sent from my iPhone using Tapatalk

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

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

Re: Script that compare temperature reading from two sensors

Thank you Flyingdiver, I'm not getting a different error message, please see screenshot below.
Attachments
Screen Shot 2020-11-05 at 8.15.57 am.png
Screen Shot 2020-11-05 at 8.15.57 am.png (187.14 KiB) Viewed 2413 times

Who is online

Users browsing this forum: No registered users and 6 guests