[SOLVED] Warn: no viable alternative at input

Hi,
The following simple rule compares temperature (Number Items) to a predefined value, and send a push notification if temp. is higher than the value. Unfortunately this rule always throws “no viable alternative at input” warn. Do you have any ide what is wrong in this rule?

2018-10-13 19:24:20.538 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'custom.rules' has errors, therefore ignoring it: [122,83]: no viable alternative at input '23'
rule "Fire Alarm"
        when
                Member of Heating_temps changed
        then
                Heating_temps.allMembers.forEach[ht|
                        if ( ht.state != NULL && ht.state as DecimalType > 23 && Fire_Alarm_Sent.state == OFF ){
                                sendBroadcastNotification("Might be fire here: "+ht.label)
                                Fire_Alarm_Sent.sendCommand(ON) //Send push only once
                        } else if ( ht.state != NULL && ht.state as DecimalType =< 23 ){  //this is the line 122
                                Fire_Alarm_Sent.sendCommand(OFF) // reset status 
                        }
                ]
end

Thanks.

The last bracket is ] should be }. Move the ] bracket to be above the } and try. Also the less than sign should be <= in your else if statement.

Need to define ht.state as a var then use in the rule.

Try that:

rule "Fire Alarm"
when
    Member of Heating_temps changed
then
    Heating_temps.allMembers.forEach[ ht |
        if (ht.state != NULL) {
            var htTemp = ht.state as Number
            if ( htTemp > 23 && Fire_Alarm_Sent.state == OFF ) {
                sendBroadcastNotification("Might be fire here: "+ ht.label.toString)
                Fire_Alarm_Sent.sendCommand(ON) //Send push only once
            } else if ( htTemp <= 23 ) {  //this is the line 122
                Fire_Alarm_Sent.sendCommand(OFF) // reset status 
            }
        }
    ]
end
1 Like

Wish I were on my OH server.:grin:
@vzorglub it’s moments like this when you realize just how much VSCode helps.

Yes indeed
Tidying up the indentations is always the first step

Thank you variable definition was missing.

Please mark the thread as solved by clicking on the square box on the post that provided the solution. e.g @vzorglub post #3 was the solution.

Thanks

You are right VSCode extension looks really useful. I am trying to configure although it is still not working.
My openhab runs on an rpi on localhost. I configured the host IP and port, but should I configure a password to make it work?

No the =< should have been >=
Your code otherwise was sound
I just tidied it up and made it easier to read