[SOLVED] Moving lower level

Hi everyone!

I am running Openhab2.4 stable release on raspi 3b.

At the moment i try to setup a rule to control the humidity (water dispenser) in my livingroom. Due to the fact that i want to change the level trough out the day (to save water and electricity) i wanted to setup a rule with a moving activating and deactivating state.

Rule is done in Habmin

// This rule file is autogenerated by HABmin.
// Any changes made manually to this file will be overwritten next time HABmin rules are saved.

// Imports
import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*
import org.java.math.*

// Global Variables

// Constants used to generate this rule
// MinHumidWZ == 45  _*(it works with the constant as the low level)*_

rule "Luftfeuchte Wohnzimmer"
when
    Item SonoffWohnzimmerHumid changed
    or
    Item EG_Soll_humid changed
    or
    Item SonoffWZLuftbefeuchter changed
    or
    Item Rolladen changed
then
  if (((SonoffWohnzimmerHumid.state >= EG_Soll_humid.state) && (SonoffWZLuftbefeuchter.state == ON))) {
    sendCommand(SonoffWZLuftbefeuchter, OFF)
  }
  else if (((Rolladen.state = OFF) && ((SonoffWohnzimmerHumid.state <= (EG_Soll_humid.state as DecimalType - 5)) && (SonoffWZLuftbefeuchter.state == OFF)))) {
    sendCommand(SonoffWZLuftbefeuchter, ON)
  }
end

The Item Rolladen indicates that everyone is a sleep so no humidifiing in the livingroom needed at all.

For some reasons the rule is not triggering if i lower the “Soll_humid” value below the actual level.

Number items are: SonoffWohnzimmerHumid and EG_Soll_humid
Switch items are: SonoffWZLuftbefeuchter and Rolladen( state ON = shutters down)

Can you please help me here?

Put some debug in there. You have an if and an else if. You couldn’t be falling through.
Print out each variable and see the state in logs.

You shouldn’t have those imports

First, remove those import, you don’t need them in OH2
There is an error in the rule:

Rolladen.state = OFF

Should be:

Rolladen.state == OFF

Add some logInfo and see what happens in the logs:

rule "Luftfeuchte Wohnzimmer"
when
    Item SonoffWohnzimmerHumid changed or
    Item EG_Soll_humid changed or
    Item SonoffWZLuftbefeuchter changed or
    Item Rolladen changed
then
    logInfo("SonoffWohnzimmerHumid: ", SonoffWohnzimmerHumid.state.toString)
    logInfo("EG_Soll_humid: ", EG_Soll_humid.state.toString)
    logInfo("SonoffWZLuftbefeuchter: ", SonoffWZLuftbefeuchter.state.toString)
    logInfo("Rolladen: ", Rolladen.state.toString)
    if (((SonoffWohnzimmerHumid.state >= EG_Soll_humid.state) && (SonoffWZLuftbefeuchter.state == ON))) {
        SonoffWZLuftbefeuchter.sendCommand(OFF)
    } else if (((Rolladen.state == OFF) && ((SonoffWohnzimmerHumid.state <= (EG_Soll_humid.state as DecimalType - 5)) && (SonoffWZLuftbefeuchter.state == OFF)))) {
        SonoffWZLuftbefeuchter.sendCommand(ON)
    }
end

Thank you that solved the problem.

Those imports originate from habmin rules creator.

I deleted them.

Best

Thecoolun

Please tick the solution, thanks