Indoor Humidity Calculation Based on Outdoor Conditions

Hi everyone, I wanted to share a little project I’ve been working on to help manage indoor humidity during the colder months. As winter approaches, maintaining a comfortable humidity level can be tricky, especially when it gets too dry. I’ve found that opening windows at the right time can make a big difference, but knowing when to do so isn’t always straightforward.

Here’s what I came up with: a rule that calculates the expected indoor humidity based on outdoor conditions. This way, you can automate actions like opening windows or adjusting your humidifier. The rule takes into account outdoor temperature and humidity, then calculates what the humidity would be if you brought that outdoor air inside and heated it to your current indoor temperature.

Here’s how it works:

  1. Outdoor Sensors: You’ll need sensors for outdoor temperature and humidity.
  2. Indoor Sensors: An indoor temperature sensor is essential, and an indoor humidity sensor is helpful for comparison.
  3. Rule Setup: The rule triggers when outdoor temperature or humidity changes.
  4. Calculations: It calculates the saturation vapor pressure, partial water vapor pressure, absolute humidity, and finally the expected indoor humidity.
  5. Automation: You can set up actions based on the expected humidity, like opening windows if it’s lower than current indoor humidity or advising to close them if it’s higher.

Here’s the rule code I’ve been using:

plaintext
rule “Expected Humidity”
when
Item Outdoor_Temp changed or Item Outdoor_Humidity changed
then
var Number e_sat_w
var Number e_sat_w_in
var Number e_par
var Number e_par_in
var Number rho_D
var Number humidity_ex
val Number t_out = (Outdoor_Temp.state as Number)
val Number t_in = (Indoor_Temp.state as Number)
logInfo(“math.rules”,"T out is " + t_out)
logInfo(“math.rules”,"T in is " + t_in)
e_sat_w = 611.2 * Math.exp((17.62t_out)/(243.12+t_out))
logInfo(“math.rules”,"Saturation vapor pressure ambient: " + e_sat_w)
e_sat_w_in = 611.2 * Math.exp((17.62
t_in)/(243.12+t_in))
logInfo(“math.rules”,"Saturation vapor pressure indoors: " + e_sat_w_in)
e_par = (Outdoor_Humidity.state as Number) / 100 * e_sat_w
logInfo(“math.rules”,"Partial water vapor pressure: " + e_par)
rho_D = e_par / (461.51 * (t_out + 273.15))
logInfo(“math.rules”,"Absolute humidity in kg/m^3 " + rho_D)
e_par_in = rho_D * (461.51 *(t_in + 273.15))
humidity_ex = 100 * e_par_in / e_sat_w_in
logInfo(“math.rules”,"Expected indoor humidity: " + humidity_ex)
Humidity_Expected.postUpdate(humidity_ex)
end

I’d love to hear if anyone else finds this useful or has suggestions for improving the calculations! It’s been a fun project and has already helped me keep my home more comfortable during the colder months.