Action based on comparison of two temp sensors?

Back in the good old days I could do this with manual programming in webCORE.

Is there any way to do this in the new SmartThings architecture?

I want a window fan (outlet) to only come on if one sensor’s temperature is higher than another sensor’s temperature. All I can see now is comparing one sensor’s temp to a specific value.

1 Like

Something like this? If either one of these temperature values is above 75, turn on a fan:

Not quite. Basically:

if (TEMP1 > TEMP2) then: turn on FAN1;
if (TEMP1 < TEMP2) then: turn off FAN1;

Not based on any specific temperature.

Ah yeah, something like that is supposedly coming with the rules API (I can’t remember what it’s called anymore).

1 Like

Hmm, so that could be promising… eventually? But I wonder is there anything I can do that would work today. Even if it makes use of a legacy system that will be going away eventually. webCORE is no more, right?

As far as I know webCore still works, but it days are numbered. They have not said when it will be shut down. I would guess before the end of 2022, but I could be wrong.

1 Like

Yes, the Rules API has been able to do that for a very long time.

1 Like

From what I can see about the “Rules API”, it is a far lower-level language that what we’ve been accustomed to with webCoRE. Something that used to take a few lines of Groovy code now take pages of Rules API code. It’s not a practical replacement for the same niche. I’m not looking to be a commercial ST app developer… I just want a bit more flexibility than the incredible over-simplified options in the Android Automations UI.

Is there anything in-between? Groovy even made sense for non-programmers (although I have a programming background, I have no interest in maintaining 3 pages of code to toggle a fan on/off). I don’t mind changing gears, but there’s a difference between “sorry your old cell phone doesn’t work, here’s the new phone you need to buy” and “sorry your old cell phone doesn’t work, here’s a slab of silicon and a book on how to make ICs.”

4 Likes

As a Rule you could compare the temperature from two devices and switch another device on as the result in one line of text if you really want to. I’d probably use twenty-six because I like it that way. A fairer comparison with webCoRE would be twenty. It is logically at the same level, and the webCoRE piston language is just a front end presentation like Routines are. We haven’t seen the rules creator yet.

Each to their own though.

I am not proficient at lower level programming. BTW Webcore is a “code generator” that’s why we like it.
Most times my questions get an answer that tells me what to do not how to do it. How would I approach this with a rules generator.
My
if (TEMP1 > TEMP2) then: turn on FAN1;
if (TEMP1 < TEMP2) then: turn off FAN1;

would bring cool air in to my root cellar to cool it off.

Thanks (I miss Webcore)

I would look at sharptools.io which has a more complex set of options for routines as well as being able to create and manipulate variables.

I have yet to find a way with Sharptools to replicate this behavior. My aim is simple (in Webcore world):

 *If  sensor A temp value =/<  sensor B temp then trigger event*

Sharptools has a variable creator, but I cannot see to figure out how to feed a dynamic value for sensor A temp into a declared variable

Here is setting a variable based on device temp:

And here is comparing two temps and taking an action:

1 Like

Many thanks @h0ckeysk8er; exactly what I needed. Can I ask where/how you discovered this?

trying to figure if I missed in help documentation somewhere…

Honestly, just a little trial and error. :slight_smile:

1 Like

:point_up:I got distracted with another meeting before I could finish posting this reply, but it looks like @h0ckeysk8er has you taken care of. I’m posting it anyway as there’s some other tidbits in there that might be helpful to you…

You would need to copy the sensor values into a variable. You can do this one of two ways.

  1. Create a separate rule with a trigger for the value changing and in your flow use the Set Variable block along with the Context Variable for the event value (eg. $context.event.value)

    Then you could use the variable in a comparison in another rule as needed.

  2. In your rule, just before you get to the expression or comparison, use a Set Variable block to copy the device value into your variable.

Note that depending on what your trigger(s) are, you might be able to use Context Variables in the second approach too, but if the rule is triggered based on either of the variables changing, sometimes it’s easier to just snapshot a device’s value to a variable anyway.

Also note that in the IF Condition the left side of the comparison can contain a device value directly so you may only need to snapshot one of the values into a variable as shown in the screenshot.