Set a window of time to count notifications and trigger a switch

In a Rule, I would like be able to set a specific window of time in which I could count a number of notifications and if the number of notifications exceeded a threshold it would trigger an event. Ex Set a 10 minute window of time; set notifications from a humidity sensor to notify every 3% rise in humidity, If three notifications come in during the 10 minute window, then send a trigger to turn on the ceiling fan.

I've got something in mind, but need to go file a bug report first because while attempting to create a Rule to suit your requirements, something went wrong in RM.

In the meantime, may I ask, would it be sufficient here to simply test whether the Humidity Sensor reading had gone up by 9%, as a test (instead of counting Notifications)?

NOTES

• Edge case to consider: Notification count could rise by +2 during minutes 6-9, and again by +1 during minute 4 of the following 10-minute cycle, yet your Rule will not Trigger due to the boundary crossing.

• I'm thinking you'd need to use the Rule's Private Boolean (setting it to False during each 10-min. cycle, to prevent duplication), as well as declare two custom Variables (call them CurrentHumidity = [sensor reading] and Count = 0) to be used as test values in Actions.

I'm curious to see what @LibraSun came up with as something like this has been asked for before but it wasn't really do-able without some shortfalls. More specifically, the 10 minute windows wouldn't be floating, but would be static cycles; e.g., 5:00-5:10, 5:10-5:20, etc. So you'd possibly miss events. If you had five come in between 5:05-5:10 and five more 5:10-5:15, it wouldn't trigger.

More on point to what you're trying to do, there's a community app that I think would fit the bill. It was meant for bathrooms, but I don't see why it wouldn't fit your need.

1 Like

Thank you for your replies. This is for a bathroom fan rule. I have the humidity sensor set to send a notification everytime the humidity changes by 3%. I had it at 1% and 2% but it ended up turning on the fan at odd times vs when the shower was on. 3% seemed to stabilize that problem. The humidty will only go up rapidly when the shower is on. Maybe the interval should be 4 or 5 minutes and two 3% change notifications. I would have to test the rule with different parameters. The interval would have to work 24/7 it could not be a time of day setting. The problem of not having any time interval is that increasing the humidity notification interval to 6% or more might trigger the fan if the humidty went up by 6% over a several day period. Also, if it is too large an humidity notification interval, the steam would have really built up before the fan triggers. That is kind of like setting the fan to turn on when the humidity increases to 75%.

I will look at the Bath Fan Automating Apps.

1 Like

That app will do exactly what you want. I use it for all my bathrooms. Below is my setup for the master bath. The fan is usually on by the time the water finishes warming up. Dialing in the range may take some trial and error to get right. Factors like what your normal humidity is and where your humidity sensor is placed will come into play. I think the hardest part was getting it adjusted so that the fan doesn't run for forever after a shower.

1 Like

For sh!tz and giggles, here's a rough sketch (in pseudocode) of a Rule I might concoct, but currently cannot test due to certain limitations in the firmware I'm using...

RULE SETUP

Define var timeStamp = (now)
Define var baseHumid = (current humidity sensor value)
Set privateBoolean = TRUE

RULE STRUCTURE

Required Condition: privateBoolean = TRUE
Trigger: Humidity sensor value *increased*
SET privateBoolean = FALSE
IF (current humidity sensor value) > baseHumid + 9
  IF (now) - timeStamp <= 10 minutes
    Turn on Device: Fan
    Delay 10 minutes
    Turn off Device: Fan
  END-IF
  SET baseHumid = (current humidity sensor value)
END-IF
SET timeStamp = (now)
SET privateBoolean = TRUE

Obviously, as illustrated above, there exist better, more suitable turnkey solutions, but if you decide to roll your own, I felt obligated to chime in with this (untested, likely invalid) suggestion. :smiley:

Thanks. My Humidity sensor (Zooz ZSE44) only sends notifications on a set % humodity change. It has to be pretty low in order to trigger the fan before the steam fills the bathroom. But setting it at 1% will kill the battery quickly. It is not able tp send a notification when it hits a certain humidity level. The On Humidity Level and Off Humidity Level is being done in the Hubitat Simple Automation Tool which is where the fan switch triggers. The trick if to have it turn on the fan when the humidity rises quickly over a cewrtain level, but not when it rises slowly to that level because of rising ambient humidity. Maybe I should just set the fan to come on when the light switch over the shower is turned on.

1 Like

Sounds a tad more reasonable and practical:
LIGHT ON? OK
IS HUMIDITY > Setpoint? Turn on fan.
Turn off fan later (time) or N minutes after light out (switch). :slight_smile:

I'm using the same humidity sensors in all my bathrooms. I have the sensors themselves set to report on 5% humidity changes.

There's an expander arrow in the app that explains what each setting does. To use my screenshot as an example:

The fan will turn on any time there's a report of humidity over at or over 70%. It will also turn on if the rate of change is greater than 1%/minute (the rate of change is more or less what you were trying to do with your rule) and the humidity level is at least 60%. It will automatically turn the fan off whenever the runtime hits 60 minutes.

These app settings do not change anything with the device reporting. The device will continue to report based on what is set in the device page.

1 Like