My brain must be fried these days. I simply cant make a simple rule optimized
This is the exsisting rules which I´m trying to optimize:
rule "Quooker ON or OFF"
when
Item FF_Sonoff_POW_Load changed
then
if (FF_Sonoff_POW_Load.state as Number >= 2){
Quooker.sendCommand(ON)
logInfo("info", "Quooker is ON")
}
else
Quooker.sendCommand(OFF)
end
Simple rule logic explained.
When Sonoff_POW changed.
If value of Sonoff_pow is bigger than 2, then sendcommand ON to Quooker item…
Else sendCommand OFF to Quooker.
Optimized:
Now, what I want to optimize is, that if the criteria is already furfilled, then do nothing…
Ie. If the value is equal to or above 2, and Quooker is already ON, then do nothing. (There is no need to update Quooker item, if its already ON).
I just cant get it to work, even though I believe it should be pretty simple as well… (Hmm I really hate that word, simple).
I tried insert:
if (FF_Sonoff_POW_Load.state as Number >= 2 && Quooker.state == ON) return;
if (FF_Sonoff_POW_Load.state as Number <= 1 && Quooker.state == ON) {
Quooker.sendCommand(OFF)
else
Quooker.sendCommand(ON)
end
But then I end up with errors
2019-11-24 21:05:38.179 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'quooker.rules' has errors, therefore ignoring it: [6,45]: no viable alternative at input '='
[6,47]: mismatched input '1' expecting '>'
[6,71]: mismatched input ')' expecting 'end'
Anyone got a hint as to how I get my brain back on track