Dynamically calculate the max humidity to avoid condensation

We have Home Assistant running in our RV with a plethora (about 14) of temperature and temperature / humidity sensors. One of the worst things in an RV is water damage, and condensation on the windows / walls due to high relative humidity can be a major cause.

Condensation is worst on the window frames which are essentially a thermal bridge straight to the outside. As the temperature drops outside, the temperature of the window frames approaches the dew point given the humidity inside, and hence causing condensation.

We have a 35 pint dehumidifier which can easily keep the humidity low, but is noisy and draws a lot of power. Further, setting the humidity too low makes the air feel too dry and isn’t very pleasant.

The solution? Dynamically calculate the relative humidity that would cause the window frames to reach the dew point and control our dehumidifier to ensure the relative humidity inside stays at or slightly below this level.

Using the August-Roche-Magnus calculation from here, I implemented a few sensors and automations in Home Assistant to achieve this. It looks like there’s a Generic Hygrostat component coming soon in Home Assistant, so when that lands I’ll be able to simplify my approach somewhat.

I’ve also added basic hysteresis to prevent the dehumidifier toggling on / off too fast since my sensors each update about every 60 seconds, so the relative humidity target is recalculated about twice per minute.

Thought I’d share in case anyone else finds this useful. It wouldn’t be too hard to extend this with other overrides, such as minimum and maximum thresholds.

Here’s the package I use to achieve this.

dehumidifier:
  sensor:
      # based on this formula: https://bmcnoldy.rsmas.miami.edu/Humidity.html
      # RH: = 100 * ( EXP( (17.625*TD)/(243.04+TD) ) / EXP( (17.625*T)/(243.04+T) ) )
    - platform: template
      sensors:
        max_humidity_allowed:
          friendly_name: Max Humidity Allowed
          device_class: humidity
          unit_of_measurement: '%'
          icon_template: mdi:water-percent
          value_template: >-
            {{ (100.0 * ( e ** ((17.625*(states('sensor.outside_temperature')|float))/(243.04+(states('sensor.outside_temperature')|float))) ) / ( e ** ((17.625*(states('sensor.inside_temperature')|float))/(243.04+(states('sensor.inside_temperature')|float))) )) | round(0) }}

  binary_sensor:
    - platform: template
      sensors:
        should_run_dehumidifier:
          friendly_name: "Should Run Dehumidifier"
          value_template: >-
            {{
              (states('sensor.inside_humidity') | float) >
              (states('sensor.max_humidity_allowed') | float)
              + (1.0 if is_state('binary_sensor.should_run_dehumidifier', false) else 0)
              - (4.0 if is_state('binary_sensor.should_run_dehumidifier', true) else 0)
            }}


  automation:
    - alias: Turn the dehumidifier on or off
      trigger:
        - platform: state
          entity_id: binary_sensor.should_run_dehumidifier
        - platform: state
          entity_id: binary_sensor.dehumidifier_status
        - platform: homeassistant
          event: start
      condition:
        condition: state
        entity_id: binary_sensor.dehumidifier_status
        state: "on"
      action:
        - service_template: >
            {% if is_state('binary_sensor.should_run_dehumidifier' , 'on') %}
            switch.turn_on
            {% else %}
            switch.turn_off
            {% endif %}
          data:
            entity_id: switch.dehumidifier

The above assumes that your temperatures are in °C. If you are using °F then the following (even more unwieldy) formula is needed:

{{ (100.0 * ( e ** ((17.625*(((states('sensor.outside_temperature')|float)-32)/9*5))/(243.04+(((states('sensor.outside_temperature')|float)-32)/9*5))) ) / ( e ** ((17.625*(((states('sensor.inside_temperature')|float)-32)/9*5))/(243.04+(((states('sensor.inside_temperature')|float)-32)/9*5))) )) | round(0) }}
7 Likes

I’ve found integration does a reasonable job of predicting condensation:

3 Likes

That’s definitely a little simpler way of calculating it! The reason I didn’t choose to use it was because it was a little opaque as to what the output really means - just that a higher number means a higher chance of mold.

I think what I might do is create the mold indicator sensor and begin tracking its value - I can see over time then how well each of these approaches is correlated with our real-world experience.

1 Like

I’ve found that for my windows/calibration if the outside temperature is below 10°C and the condensation chance goes above 70% I have to run the dehumidifiers.

Would be interested in seeing your comparison results. I tried this last time a vapour pressure sensor was shared. I didn’t find any advantage over the core mold sensor.

I’ve also been wondering what the result of the Mole Sensor actually meant as well, as it always seem to be at 70%.

I’m not sure if your calculation relates to the mold sensor, but as of now, your sensor is at 79, and the mold sensor is at 69.

Did you calibrate the mold sensor as explained in the documentation?

Sure did, it’s currently reading 79%.

I am most curious about your density of temp /humidity sensors. Do you have a massive rv, great concerns about temperature and humidity variations, or just a sensor hording tendency?!

There two custom components you might like to look at:

Our RV is small - maybe 180sqft. It’s possible I do have a minor obsession with sensor hoarding, but I’ve tried to be very deliberate about where the sensors are - each one is giving us data that would change a decision we make, or at the very least, useful information.

For example, we’re going to spend this winter in very cold conditions (down to around -15°F / -25°C) which isn’t easy in an RV. Lots of things can go wrong. So we’ve got temperature sensors on various parts that are at risk of freezing - the water pump, fridge coil, underbelly, etc. We have sensors inside various parts of the RV so we can understand where the cold spots are and where we might benefit from more insulation - e.g. the storage bay. Then there are also some specialist areas, such as our fridge, freezer and hot water tank where knowing the temperature is useful (is our freezer too warm or our fridge too cold?).

So I’d say it’s a combination of looking for interesting trends, identifying areas of concern / opportunity, and monitoring for safety.

1 Like

Thanks @nickrout! I’m really hoping that the “official” core component will drop in the near future (the pull request was approved a month ago) and so I was holding off until then. But if it doesn’t quite offer what I’m looking for, then I’ll probably adopt one of those custom components.

Tasmota firmware on ESP8266 devices with sensors like BME280 (temperature and humidity) automatically calculate Dew point too, and push this value through MQTT straight to Home Assistant. No need to do further calculations, can be set up just like a simple sensor.

  - platform: mqtt
    name: "Labor Dew Point"
    state_topic: "tele/wemoslabor/SENSOR"
    value_template: "{{ value_json['BME280'].DewPoint }}"
    unit_of_measurement: "°C"
    device_class: temperature
    force_update: true
    availability_topic: "tele/wemoslabor/LWT"
    payload_available: "Online"
    payload_not_available: "Offline"
2 Likes