How can i compare Two NumberItems?

I`m trying to compare two Numeber in a rule

Number Heizung_WZ     
Number Temp_WZ   
if (Temp_WZ.state < Heizung_WZ.state){
             Boost_Aktor_Bad_Eg.sendCommand(ON)
            }

I`m getting an error Message in Visual Studio Code which i use for editing
Type missmatch: cannot convert from state to number or
cannot convert from NumberItem to number

Can someone pls help ?

If it`s needed this is my complete Rule:

rule "Lüften Wohnbereich"
    when
      Item Contact_Wohnzimmer changed or
      Item Contact_Esszimmer  changed 
    then
      switch Contact_Wohnzimmer.state {
        case OPEN: {
          Heizung_WZ.sendCommand(5)
        }
        case CLOSED: { 
          Heizung_WZ.sendCommand(Heizung_WZ.previousState(true,"mysql").state.toString())
            if (Temp_WZ.state < Heizung_WZ.state){
             Boost_Aktor_Bad_Eg.sendCommand(ON)
            }
        }
      }
      switch Contact_Esszimmer.state {
        case OPEN: {
          Heizung_WZ.sendCommand(5)
        }
        case CLOSED: { 
          Heizung_WZ.sendCommand(Heizung_WZ.previousState(true,"mysql").state.toString())
            if (Temp_WZ.state < Heizung_WZ.state){
             Boost_Aktor_Bad_Eg.sendCommand(ON)
            }
        }
      }
end
rule "Lüften Wohnbereich"
    when
      Item Contact_Wohnzimmer changed or
      Item Contact_Esszimmer  changed 
    then
      var TempWZ = Temp_WZ.state as Number
      var HeizungWZ = Heizung_WZ.state as Number

      switch Contact_Wohnzimmer.state {
        case OPEN: {
          Heizung_WZ.sendCommand(5)
        }
        case CLOSED: { 
          Heizung_WZ.sendCommand(Heizung_WZ.previousState(true,"mysql").state.toString())
            if (TempWZ < HeizungWZ){
             Boost_Aktor_Bad_Eg.sendCommand(ON)
            }
        }
      }
      switch Contact_Esszimmer.state {
        case OPEN: {
          Heizung_WZ.sendCommand(5)
        }
        case CLOSED: { 
          Heizung_WZ.sendCommand(Heizung_WZ.previousState(true,"mysql").state.toString())
            if (TempWZ < HeizungWZ){
             Boost_Aktor_Bad_Eg.sendCommand(ON)
            }
        }
      }
end
1 Like

sometimes it`s so easy…
Thank you very much :slight_smile:

In your case, because you are using the Numbers several times in the rule it makes sense to put them is a var
You could also have done:

           if (Temp_WZ.state as Number < Heizung_WZ.state as Number){
1 Like