[SOLVED] Humidity Rule

Hi All

I’m trying to optimize my humidity rule, hope someone can help.

My current rule is like this:


	when
	Item Nilan_Input_RH changed
	then
	if(Nilan_Input_RH.state>=48.50) {
	sendCommand(Nilan_Control_VentSet,4)
	sendCommand(Smarthouse_Motorventil, ON)
	}

end

rule "Nilan Humidity <=48,00 Speed 2"

	when
	Item Nilan_Input_RH changed
	then
	if(Nilan_Input_RH.state<48.00) {
	sendCommand(Nilan_Control_VentSet,2)
	sendCommand(Smarthouse_Motorventil, OFF)
	}

end

As the Nilan_Input_RH.state is depending on the outside humidity and the room temperature, a fixed value is not a good choice.

I was thinking if I did a measurement over 1/2 hour and use the mean value of all measured values, and add 1 to this value - Then I should have a dynamic setpoint that takes the outside humidity and room temperature in account.

Hope someone can help me achieve this?

Best Nanna

In order to get averages you should persist the measured values in a database (rrd4j? ) and use the .averagesince function.
Look into the docs here: http://docs.openhab.org/configuration/persistence.html

Thanks @opus It works perfect :slight_smile:

This should be really simple, but some how I can manage to make this work.

I have this rule:

when
Item Nilan_Input_RH changed
then
if (Nilan_Input_RH.state >= Nilan_Input_RH_Avrg.state){
sendCommand(Nilan_Control_VentSet,4)
sendCommand(Smarthouse_Motorventil, ON)
}

What I need is simple add a fixed value (eg. 2) of to to the Nilan_Input_RH.state, så that the comparison always is 2 greater than Nilan_input_RH_Avrg.state

Can someone please tell me how, I can simply not make it work.

Try:

when
Item Nilan_Input_RH changed
then
if (Nilan_Input_RH.state as Decimal >= Nilan_Input_RH_Avrg.state as Decimal){
sendCommand(Nilan_Control_VentSet,4)
sendCommand(Smarthouse_Motorventil, ON)
}

1 Like

I need to add the fixed value 2, to the Nilan_input_RH_Avrg.state before the comparison withNilan_Input_RH.state.

How about getting the state as Decimal into a number variable, adding 2 to the variable and posting an update with this variable to the item?

To be honest I suck at creating rules :frowning:

var Number MyNumber=Nilan_input_RH_Avrg.state as Decimal
MyNumber=MyNumber+2
Nilan_input_RH_Avrg.postUpdate (MyNumber)

Thank so much for helping me understand a bit more about rules - it works perfect :slight_smile:

rule "Nilan Humidity"
	when
        	Item Nilan_Input_RH changed
	then
		var Number Humidity=(Nilan_Input_RH_Avrg.state)
		Humidity=Humidity+0.1
		Nilan_Input_RH_Trig.postUpdate (Humidity)
		if(Nilan_Input_RH.state >= Nilan_Input_RH_Trig.state){
		sendCommand(Nilan_Control_VentSet,4)
		sendCommand(Smarthouse_Motorventil, ON)
		}
	
	else if (Nilan_Input_RH.state < Nilan_Input_RH_Trig.state) {
		sendCommand(Nilan_Control_VentSet,2)
		sendCommand(Smarthouse_Motorventil, OFF)
		}
end