# Relative Humidity Trigger Help

#1

1) Give a description of the problem
Need to set up a trigger that fires when relative humidity increases by a certain percentage (or more ideally, a certain number of percentage points) within a given amount of time). I currently have it set to fire when humidity increases beyond a certain value. In other words, I want: (“fire when humidity increases by 10% in 5 minutes or less” – rather than “fire when humidity exceeds 75%”

2) What is the expected behavior?
I have my bathroom lighting set to change when a shower is detected. When humidity changes enough (shower detected) the lights change. Currently, my trigger is when humidity rises to 75% or greater.

3) What is happening/not happening?
The piston works fine except for this problem: On cold days when the air is extra dry, the shower doesn’t cause the humidity to rise above 75% or for long enough, so the lights don’t change. On warmer, more humid days, it’s not an issue. I want this trigger to work regardless of what the baseline humidity is that day. I want the code to basically evaluate: “Has humidity risen X percentage points in the last X minutes.” I will also need the false statement of this trigger (if that’s the right term) because I have other conditions that currently say, “if humidity is below 75%, then do this instead.” So if I switch up this trigger, I will also need to know how to code the false version of that as well. Hope that makes sense.

4) Post a Green Snapshot of the piston

Not needed. Piston works except for trigger.

5) Attach any logs (From ST IDE and by turning logging level to Full)
(PASTE YOUR LOGS HERE BETWEEN THE MARKS THEN HIGHLIGHT ALL OF THE LOGS SND CLICK ON THE </> ICON TO FORMAT THEM)

If a solution is found for your question then please mark the post as the solution.

#2

Hard to give solid advice without seeing what you have, but why not some variation of this:

``````When Bathroom motion changes to active
Set variable {currentHumidity} to current humidity
``````

Then you can base your logic on {currentHumidity} * 1.1 (which is a 10% increase)

#3

That sounds on the right track, but I’m afraid I’m quite a noob. Not sure if I know how to set variables and work that into a condition. I’ve attached the full piston here. You’ll see that the idea is that in non-shower conditions (no big humidity shift), lights follow certain settings and auto-off intervals based on motion and time of day. If shower is detected (in it’s current form, higher than 75%), then the lights fade up in temp and level and stay on until humidity drops and no motion is detected. Hope that makes sense. Any help would be greatly appreciated.

Thanks

#4

I will be honest, there are about a dozen things I would do differently in your piston, but I do not have the freetime to re-write this from scratch…

Here are a few pointers that may get you headed in the right direction:

Variables are created in the top “define” section. You can make this section visible by editing the piston, clicking on “Options” in the top right, and then checking “Show variables”.
(the only other checkmark I might recommend for newbies is “Show advanced statements”. All the others will likely confuse at this point.)

When adding the new variable to the define section, you likely want “Number integer” for your humidity. (although, If your device shows decimal places, then you’ll want to choose “Number decimal”). Give it a name, but leave the second line blank.

Once it is defined up top, then you can set the variable by using the command:

(replacing my AccuWeather with your device, of course)

Then to use that as a conditional later on in your code, you can create an “IF block”, something like this:

This will be true if the humidity has risen 10% from whatever the variable was set to earlier.

Hopefully, this helps teach some basics, and someone else can chime in with more specifics.

#5

I will be honest, there are about a dozen things I would do differently in your piston, but I do not have the freetime to re-write this from scratch…

I don’t doubt it. I’m very new to ST, coding, and WebCore, so I’m sure my setup is pretty crude. Really appreciate all this advice.

#6

One quick question- why wouldn’t you set the If block to compare the device itself against the variable, since the variable is static once set and can’t detect the rise in humidity? Such as: IF humitidysensor1’s humitidy rises above currenthumidity * 1.1 THEN…

I ask because I’m trying to set up the false version of this for the non-shower conditions.