- Code: Select all
Outdoor Temp Indoor Humidity
+40°F 45%
+30°F 40%
+20°F 35%
+10°F 30%
0°F 25%
-10°F 20%
-20°F 15%
The 10° range between temperatures means that the outside temperature of 39° will call for 40% humidity (even though you'd want closer to 45%.) Since the relationship between temperature and humidity is linear (and because I can't leave well enough alone), I came up with the formula:
- Code: Select all
targetHumidity = 45 - ((40 - currentTemp) / 2)
So I run this every 15 minutes:
- Code: Select all
currentTemp = float(indigo.devices[12345678].states["temp"]) # "OUTSIDE TEMPERATURE"
# not more than 45% humidity
if currentTemp >= 40:
indigo.variable.updateValue(12345678, '45')
# not less than 15% humidity
elif currentTemp < -20:
indigo.variable.updateValue(12345678, '15')
# temperature is between -20 and 40
else:
targetHumidity = 45 - ((40 - currentTemp) / 2)
targetHumidityRnd= round(targetHumidity)
targetHumidityInt= int(targetHumidityRnd)
targetHumidityStr = str(targetHumidityInt)
indigo.variable.updateValue(12345678, targetHumidityStr)
[EDIT} Takes out an unnecessary python variable.