Comparing the difference between 2 devices


#1

Hello All- I’m new to the forum and advanced piston design. I think I need help with either creating a variable or expression. I’ve done neither. [PROBLEM] I will have 2 humidity sensors. When the humidity of Sensor 2 is 10% higher than Sensor 1 I want to turn on a fan. I really just want the best way to do this. Other posts seem to indicate that similar things are done with a variable or expression. That seems to be my hang up.

So far I’ve not been able to create anything that will make the fan come on.


#2

You can use a device reference for the first part, but you will need an expression for the second part of the If.
It would read

If
    motion_sensor's humidity remains above or equal to {[other_motion_sensor:humidity]+10}%
then

Creating it looks like this:


(I only have one humidity sensor. In your case they would be different sensors)


#3

Thank You.

I think I followed your steps, but it doesn’t seem to be working. I’m sure I missed something. Because the humidity sensors won’t be here until tomorrow, I’m using 2 temperature sensors to experiment with.

Contact Sensor 1 is currently 88*
Multipurpose Sensor is currently 74*
74* + 10 is 84*, so I would think this should have turned on the lights as a test. It did not. Does this explanation make sense?


#4

Changing the “remains above or equal to” to “greater than” worked. It turned on the light in the above test. I don’t know what the difference is. Should this be reliable?


#5

It should be a comparison listed under the heading “Triggers” rather than “Conditions” so that it will subscribe to events. You could try “stays greater than for 30 seconds” (or whatever time period you think appropriate).


#6

That’s what I’m missing! Then how would I reverse it and shut off the fan, (light in my current test) when the humidity falls back below the trigger?


#7

Same idea:

If
    motion_sensor's humidity stays less than {[other_motion_sensor:humidity]+10}% for 30 seconds
then

Although, on thinking about this, I’d probably set the time limit to 1 minute or even more just to prevent thrashing.


#8

Okay. So this would be 2 separate pistons, correct? Not using the “else if”.


#9

I would make it two separate pistons. It simplifies working through the execution.


#10

Done, but they seem to get stuck on either both true or both false at the same time.


#11

Yeah. Oops the second one should read less than {[other_motion_sensor:humidity]-10}%
(Minus 10%, not plus 10%) [sigh] That’s exactly the “thrashing” I meant to prevent.


#12

I think that did it for the true false issue. Still testing. Is there a time frame on the “remains” above or below? I’m using 2 temperature sensors to test this and it does not change to on or off when the temperature condition is met. There seems to be about 5 minutes of delay after the temperature condition is met.



#13

I might have my +2 and -2 backwards


#14

On piston “qw4a”:

74 + 10 is less that 88, so it should not have fired


#15

@WCmore You are correct. Perhaps I need to go back to that one and start over. I think I was looking at it too hard… hmm. How could I have missed that??? I think I might be over complicating this thing. It should be pretty simple to turn on or off.


#16

This one seems to be working. I just need to swap out temperature for humidity when the sensors get here tomorrow. Do you see any issues with this one?


#17

It might work. I dunno. I code very differently.
(I’ve never tested code written this way before)


Personally, I would turn off
Options > Show when true/false actions
and instead use the THEN section for your “Turn on” command


#18

Thank you!
It is the only piston I have that uses the “true/false”. When I use the “then” this one gets hung up. I’m using 2 multipurpose sensors, the sun and a refrigerator to simulate the atmosphere temperature to fire the triggers. I’ve also changed to “remains below” as my trigger. Do you know how long it must remain below before it fires?