Syntax for If question

Hi There,

Can someone give me a hint how to compare in the rules a value > than:

my problem:

when
    Item Cat_wants_out received command
then
    if ((receivedCommand == ON) && (EG_WO_Rolladen_Links>30))
    {
       
        {
        sendCommand(EG_WO_Rolladen_Links, 30)
        }
        
    }
end


My error Message:

2020-01-24 23:45:26.738 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Maxi Will raus': Unknown variable or command '>'; line 8, column 37, length 23

Try spaces around > ?

Your issue is not the > operator… you are comparing an Item to a number. You should compare the Item’s state to the number…

when
    Item Cat_wants_out received command
then
    if (receivedCommand == ON && EG_WO_Rolladen_Links.state > 30) {
        sendCommand(EG_WO_Rolladen_Links, 30)
    }
end

If the Item state is a QuantityType, then more is needed.

Is that an Item? If so, you are probably interested in its state (as opposed to label, type, icon, or other properties of the whole object)

(EG_WO_Rolladen_Links.state > 30)

To explain the odd error message, rules guesses what you mean by > based on the preceeding value. Which in this case, made no sense. Give it a numeric value, and it understads > is for “greater than” rather than say. one of a pair like <somevalue>

Depending on the Item type, you might need to do further massaging to turn a state into a number

( (EG_WO_Rolladen_Links.state as Number) > 30)

1 Like

Thank;

solution was simply using .state

(EG_WO_Rolladen_Links.state > 30)