Bathroom Humidity Automation - how to set Lutron switch for on x 45 minutes and based on humidity?

I have a Panasonic WhisperWarm fan and am using the Lutron Casta 6amp on/off switch for the exhaust component. Also have a Sonoff humidity sensor in the bathroom.

I currently have a very simple Node Red automation that if bathroom humidity exceeds 60% to turn the exhaust on until drops below 55% but I have two other conditions (?) that I would like to control for as well.

  1. If switch manually turned on (boy needs to use bathroom…), switch should turn off after 45 minutes
  2. If switch turned on manually but humidity higher than set point and/or rising, switch should stay on past the 45 minute window to account for humidity as well (boy likes to use toilet then shower and can be in there for an hour easily…)
  3. If outside humidity very high and rest of home above 55%, there is no way the exhaust will pull moisture to drop below the set point of 55% so how do I take that into account. I have other humidity sensors in bedrooms on the second floor that I can use to compare.

Thanks!

You could consider to first calculate the absolute humidity outdoor and indoor. Then you don’t have the influence of the difference of temperature outside and inside. The air pressure also influence the relative humidity, but the air pressure inside and outside will be the same most of the time.

Comparing outside and inside absolute humidity is easy and reliable.

This is what I have so far in Node Red that seems to work on 1 and 2. Not sure how best to calculate absolute humidity with HA nor use it here or in an Automation as a condition with the above.
Note: the delay is now 40 minutes - this was an earlier screenshot

This is the algoritme:

EXP = 2.71828182845904523536028747135266249775724709369995
humidityAbs = 0.622 * hum/100 * (1.01325 * 10^(5.426651 - 2005.1 / (temp + 273.15) + 0.00013869 * ((temp + 273.15) * (temp + 273.15) - 293700) / (temp + 273.15) * (10^(0.000000000011965 * ((temp + 273.15) * (temp + 273.15) - 293700) * ((temp + 273.15) * (temp + 273.15) - 293700)) - 1) - 0.0044 * 10^((-0.0057148 * (374.11 - temp)^1.25))) + (((temp + 273.15) / 647.3) - 0.422) * (0.577 - ((temp + 273.15) / 647.3)) * EXP^(0.000000000011965 * ((temp + 273.15) * (temp + 273.15) - 293700) * ((temp + 273.15) * (temp + 273.15) - 293700)) * 0.00980665) / (press/1000 - hum/100 * (1.01325 * 10^(5.426651 - 2005.1 / (temp + 273.15) + 0.00013869 * ((temp + 273.15) * (temp + 273.15) - 293700) / (temp + 273.15) * (10^(0.000000000011965 * ((temp + 273.15) * (temp + 273.15) - 293700) * ((temp + 273.15) * (temp + 273.15) - 293700)) - 1) - 0.0044 * 10^((-0.0057148 * (374.11 - temp)^1.25))) + (((temp + 273.15) / 647.3) - 0.422) * (0.577 - ((temp + 273.15) / 647.3)) * EXP^(0.000000000011965 * ((temp + 273.15) * (temp + 273.15) - 293700) * ((temp + 273.15) * (temp + 273.15) - 293700)) * 0.00980665)) * press/1000 * 100000000 / ((temp + 273.15) * 287.1)

(hum = relative humidity, temp = temperature, press = air pressure (also can be the average 1013.25))