If condition in Rule Engine (Experimental)

Hi,

i’ve just added a thing in “Paper UI” wich sets the wanted temperature via “HABPanel”. Then I got a value of a sensor wich I want to compare with for switching a heater.

I added a rule in “Rule Engine” wich send a command when an item state is updated of the sensor or the item where I set the wanted temperature. It works perfectly but when I add the condition via “but only if…” the command is sended in every case.

For example I simplified it and add the condition if(1 > 2) and the command is sended.

What do I wrong by adding a condition?

I want this working:

if((sensor.state as as DecimalType) < (wanted.state as as DecimalType))

Thank you!

TOPIC WAS CLOSED AND I COULDN’T REPLY BUT MAKE THIS ADDITION:

If you work with the “Next Rule Engine” don’t choose “a given script evaluates to true”. I’m sure that this option doesn’t work proper at this moment. Try to experiment with “an item has a given state”. In most cases i’ve got the rule working properly. Sometimes it is better to make a rule manually as a file.

Double as?

And as it’s a Temperature, what’s the Item Type, is it Number or is it Number:Temperature?

Hi Udo,

the item type of both is Number:Temperature but i just tested if(1 > 2) too and the switch turns on too. I think i do a syntax error wich delivers TRUE everytime?

Best regards
Chris

Well, I don’t use NGRE, so I don’t know… but

if((sensor.state as as DecimalType) < (wanted.state as as DecimalType))

is definitely wrong. When both items are of the same type, it should just work like that:

if(sensor.state < wanted.state)

or

if((sensor.state as QuantityType<Number>).floatValue < (wanted.state as QuantityType<Number>).floatValue)

Hi Udo,

i think java does not work correct because if i make a simple condition (1 > 2) it doesn’t work too.

Best regards
Chris

This script doesn’t work too:

return false

The rule execute’s the command anyway.

You cannot return anything from a rule, there is nothing to return it to.
So you just want return with no parameter.

There is a quirk however, you must terminate the return with a semicolon
return;

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.