The following app calculates the 'ideal' interior humidity for homes in cold climates. I use my smart hub to control my whole house humidifier in order to set the humidity of the home through out the winter.
If you live in a cold climate you know that if you set your interior humidity too high you will get condensation on your windows. This is bad as it can lead to rot and mold. This app takes into account the outside air temperature and calculates a humidity which will be comfortable without leading to condensation.
If you still get condensation at when you can adjust the frost factor stetting to be a negative value, this will adjust the target humidity in a downward direction. If you have particularly well insulated windows you can increase the frost factor to increase the target humidity.
This app does not control your humidity it just exposes a virtual humidity sensor which represents a reasonable humidity target
/*
Copyright 2019 Jmaxxz
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE
*/
definition(
name: "Target indoor humidity calculator",
namespace: "jmaxxz",
author: "jmaxxz",
description: "Calculates the ideal indoor humidity based on outside air tempature",
category: "Convenience",
iconUrl: "",
iconX2Url: "")
preferences {
section("Configuration") {
input "tempSensor", "capability.temperatureMeasurement", title: "Select outside temperature sensor", submitOnChange: true, required: true, multiple: false
input "minRh", "decimal", title: "The minimum target relative humidity allowed", defaultValue: 20, submitOnChange: true
input "maxRh", "decimal", title: "The maximum target relative humidity allowed", defaultValue: 50, submitOnChange: true
input "frostCorrection", "decimal", title: "Used to correct calculation by applying a fixed offset. If you set condensation on your windows set to a lower number.", defaultValue: 0, submitOnChange: true
}
}
def installed() {
initialize()
}
def updated() {
unsubscribe()
initialize()
}
def initialize() {
def targetHumidity = getChildDevice("TargetHumidity_${app.id}")
if(!targetHumidity) targetHumidity = addChildDevice("hubitat", "Virtual Humidity Sensor", "TargetHumidity_${app.id}", null, [label: "Target humidity", name: thisName])
targetHumidity.setHumidity(calculateTarget())
subscribe(tempSensor, "temperature", handler)
}
def calculateTarget() {
def double outsideTemp = tempSensor.currentTemperature
// See: http://www.vistawindowco.com/docs/default-source/pdfs/condensationlit.pdf?sfvrsn=0 for source of math
def target = Math.max(Math.min((double)frostCorrection+27.7+0.535*outsideTemp - 0.00409 * Math.pow(outsideTemp, 2), (double)maxRh), (double)minRh)
log.info "Calculated a target humidity of ${target}% RH given an outside temperature of ${outsideTemp}"
return Math.round(target*10)/10
}
def handler(evt) {
def targetHumidity = getChildDevice("TargetHumidity_${app.id}")
if(!targetHumidity) targetHumidity = addChildDevice("hubitat", "Virtual Humidity Sensor", "TargetHumidity_${app.id}", null, [label: thisName, name: thisName])
def target = calculateTarget()
targetHumidity.setHumidity(target)
}