On demand ventilation

I wanted to control the ventilation in my house. The house is controlled by a central ventilation unit that can be switched (1-2-3) from two places in the house. For this purpose extra switch cables run through the house. The fan is connected with Neutral - Phase - Switch1 - Switch2. Turning both switches OFF let the fan run at speed 1, which is default behaviour. (The ventilation unit also has a 0-10V control line that I still need to look into.)

The ventilation unit was equipped with a double zwave switch (Philio PAN06), so I could activate the MEDIUM (2) and HIGH (3) setting of the unit with Openhab. Now I needed a way to have it switch to HIGH when needed.

I already had a pair of Aeon 4-1 sensors in the house to control heating, one of which was located in the bathroom. The idea was then to compare relative humidity levels and swich the fan on if needed. I overlooked the fact that relative humidity was relative indeed, to temperature. (I don’t think the 4-1 take measures barometric pressure). Since I generously heat up the bathroom at typical times of use, the relative humidity there was lower than in other places of the house. So I had to convert the relative humidity to absolute humidity and compare the results then.

It was hard to find anything on the subject so sharing here. I probably will have to change the threshold setting to avoid pingpong behavior but for now it doesn’t seem to happen

import org.openhab.core.library.types.*
rule "Automatic ventilation"
when
    Item sen_hum_bad changed
then
    //Define threshold for fan activation as the maximum higher value of bathroom humidity
    var double dTreshold = 0.5 
        //take humidity and temperature groundfloor
        var Number n0Hum = sen_hum_wc0.state as DecimalType
        var Number n0Temp = sen_tem_wc0.state as DecimalType
        var Double d0Hum = n0Hum.doubleValue()
        var Double d0Temp = n0Temp.doubleValue()
        logDebug("rules", "Variable type and Value d0Hum: " + d0Hum.getClass().getName() + " " + d0Hum)
        logDebug("rules", "Variable type and Value d0Temp: " + d0Temp.getClass().getName() + " " + d0Temp)

        //take humidity and temperature bathroom
        var Number n2Hum = sen_hum_bad.state as DecimalType
        var Number n2Temp = sen_tem_bad.state as DecimalType
        var Double d2Hum = n2Hum.doubleValue()
        var Double d2Temp = n2Temp.doubleValue()
        logDebug("rules", "Variable type and Value d2Hum: " + d2Hum.getClass().getName() + " " + d2Hum)
        logDebug("rules", "Variable type and Value d2Temp: " + d2Temp.getClass().getName() + " " + d2Temp)
    
    

        var Double d0AbsHum = (6.112 * Math::exp(java::math::BigDecimal::doubleValue((17.67 * d0Temp)/(d0Temp + 243.5))) * d0Hum * 2.1674 ) / (273.15 + d0Temp)
        var Double d2AbsHum = (6.112 * Math::exp(java::math::BigDecimal::doubleValue((17.67 * d2Temp)/(d2Temp + 243.5))) * d2Hum * 2.1674 ) / (273.15 + d2Temp)
        logDebug("rules", "Calculated absolute humidity 0: " + d0AbsHum)
        logDebug("rules", "Calculated absolute humidity 2: " + d2AbsHum)


        
        //compare the difference between humity levels and decide if the fan should be activated
        if ((d2AbsHum-d0AbsHum) > dTreshold) 
            {
                logInfo("rules", "Automatic switching ventilation to HIGH")
                swc_ve2.sendCommand(OFF)
                swc_ve3.sendCommand(ON)
            }
        else
            {
                logInfo("rules", "Automatic switching ventilation to LOW")
                swc_ve2.sendCommand(OFF)
                swc_ve3.sendCommand(OFF)
            }


end

Hi coyote,

this is exactly what I am looking for. But I had to alter this
var Double d0AbsHum = (6.112 * Math::exp(java::math::BigDecimal::doubleValue((17.67 * d0Temp)/(d0Temp + 243.5))) * d0Hum * 2.1674 ) / (273.15 + d0Temp)
to
var Double d0AbsHum = (6.112 * Math::exp((17.67 * d0Temp)/(d0Temp + 243.5)) * d0Hum * 2.1674 ) / (273.15 + d0Temp)

Do you know why? The result seems to be ok.

Cheers

I just had a change done myself, in the same direction. For me I’m running v2.1 now and the log complained that the doubleValue method wasn’t there. I guess there are some moniro implementation changes between versions, that are probable documented in a readme somewhere.
I got rid of the includes as well, not needed in this version…

My version now reads:

rule “Automatic ventilation”
when
Item etage2BadkamerHumidity changed
then
//Define threshold for fan activation as the maximum higher value of bathroom absolute humidity
var double dTreshhold = 2.5

  //take humidity and temperature groundfloor
  var Number n0Hum = etage0WCHumidity.state as DecimalType
  var Number n0Temp = etage0WCTemperatuur.state as DecimalType
  var Double d0Hum = n0Hum.doubleValue()
  var Double d0Temp = n0Temp.doubleValue()
  //logDebug("rules", "Variable type and Value d0Hum: " + d0Hum.getClass().getName() + " " + d0Hum)
  //logDebug("rules", "Variable type and Value d0Temp: " + d0Temp.getClass().getName() + " " + d0Temp)

  //take humidity and temperature bathroom
  var Number n2Hum = etage2BadkamerHumidity.state as DecimalType
  var Number n2Temp = etage2BadkamerTemperatuur.state as DecimalType
  var Double d2Hum = n2Hum.doubleValue()
  var Double d2Temp = n2Temp.doubleValue()
  //logDebug("rules", "Variable type and Value d2Hum: " + d2Hum.getClass().getName() + " " + d2Hum)
  //logDebug("rules", "Variable type and Value d2Temp: " + d2Temp.getClass().getName() + " " + d2Temp)



  var Double d0AbsHum = (6.112 * ((17.67 * d0Temp)/(d0Temp + 243.5)) * d0Hum * 2.1674 ) / (273.15 + d0Temp)
  var Double d2AbsHum = (6.112 * ((17.67 * d2Temp)/(d2Temp + 243.5)) * d2Hum * 2.1674 ) / (273.15 + d2Temp)
  //logInfo("rules", "Calculated absolute humidity 0: " + d0AbsHum)
  //logInfo("rules", "Calculated absolute humidity 2: " + d2AbsHum)



  //compare the difference between humity levels and decide if the fan should be activated
  if ((d2AbsHum-d0AbsHum) > dTreshhold)
  	{
  		logInfo("rules", "Automatic switching ventilation to HIGH")
  		etage3Ventilatie2.sendCommand(OFF)
  		etage3Ventilatie3.sendCommand(ON)
  	}
  else
  	{
  		logInfo("rules", "Automatic switching ventilation to LOW")
  		etage3Ventilatie2.sendCommand(OFF)
  		etage3Ventilatie3.sendCommand(OFF)
  	}

end

Cheers, C