[SOLVED] Configuration model .rules has errors, therefore ignoring it: no viable alternative at input

  • Platform information:
    • Hardware: ODROID-XU4, armv7l, 2GB RAM
    • OS: Armbian (Debian) Buster with Linux 4.14.180-odroidxu4
    • Java Runtime Environment: Azul 8
    • openHAB version: 2.5.5-1 from https://dl.bintray.com/openhab/apt-repo2 (stable)

Been scratching my head on this one all day so far, searched/read through several similar topics but still can’t figure it out. Even took a break and made myself a sandwich… :smile: But still no joy.

Here is the actual error:

2020-06-09 11:08:29.504 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model '433mhz_button.rules' has errors, therefore ignoring it: [3,5]: no viable alternative at input '433'
[5,12]: missing ')' at 'toMQTT_value'
[5,38]: mismatched input ')' expecting 'end'

Complete rules file in question (433mhz_button.rules):

rule "433mhz buttons"
when
    Item 433toMQTT_value changed 
then
    if (433toMQTT_value.state == NULL)
	{
	logInfo("rule 433mhz buttons", "Item is null, cancelling...")
	return;
	} 
    var rfData = 433toMQTT_value.state.toString
    logInfo("rule 433mhz buttons", "Incoming RF code: " + rfData)
	switch (rfData) {         
	    case "969554":
	       {
		if (433_remote_button_1of5.state == ON)
		    {
		    logInfo("rule 433mhz buttons", "-> 433_remote_button_1of5.sendCommand(OFF)")
		    433_remote_button_1of5.sendCommand(OFF)
		    }
		else
		    {
		    logInfo("rule 433mhz buttons", "-> 433_remote_button_1of5.sendCommand(ON)")	
		    433_remote_button_1of5.sendCommand(ON)
		    }

		// Reset Last Received Code
		rfData=""
		433toMQTT_value.postUpdate(rfData)
	       }
	}
end

Relevant item from (433mhz.items):

String 433toMQTT_value "Received value from OMG/433toMQTT" {channel="mqtt:topic:cubietruck:OMG:433_value"}

Relevant bits of (mqtt.things):

Bridge mqtt:broker:cubietruck [ host="192.168.X.Y" ]
{
    Thing topic OMG "Open MQTT Gateway" {
    Channels:

	Type string : 433_value "name here no matter" [
	     stateTopic="home/+/433toMQTT",
	     transformationPattern="JSONPATH:$.value"
	     ]

    }

}

The .items and .things files are parsed without errors. I have rebooted the ODROID, etc. but now running out of ideas…

This one will surprise you.

(Item) Names must not begin with numbers.

2 Likes

Looks like the rules engine cannot parse your item name due to the numerals at the beginning. Try renaming all your items to start with characters.

2 Likes

Interesting!

Yeah, I would have never suspected that. Especially because I had several Items starting with numbers that were working fine before this:

Switch 433_remote_button_1of5 "Bedroom Light String" {channel="mqtt:topic:cubietruck:OMG:433_1of5"}
Switch 433_remote_button_2of5 "Living Room Light String" {channel="mqtt:topic:cubietruck:OMG:433_2of5"}

And even rules (although not triggering on the Items starting with numbers):

rule "433mhz 5 button controls"
when
    Channel "xmppclient:xmppBridge:xmpp:xmpp_command" triggered
then
    var actionName = receivedEvent.getEvent().split("##")
    //logInfo("xmpp", actionName.get(1))
    if(actionName.get(1).toLowerCase() == "turn on button 1") {
        433_remote_button_1of5.sendCommand(ON)}
    if(actionName.get(1).toLowerCase() == "turn on button 2") {
        433_remote_button_2of5.sendCommand(ON)}
    // [...]
end

So, it was not until I tried to trigger a rule based on an Item beginning with a number, that this became an issue (apparently)…

OK, let me go re-work this, and then I will report back.

Also, you guys tied for first! :smile:

OK, so I simply added an “i” in front of 433toMQTT_value to make it i433toMQTT_value. I did this in .items and .rules file.

Save the rules file, then it chokes again on some other items starting with numbers further down:

2020-06-09 12:07:15.239 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model '433mhz_button.rules' has errors, therefore ignoring it: [15,11]: missing ')' at 'remote_button_1of5'
[15,41]: mismatched input ')' expecting '}'
[16,7]: missing '}' at '{'
[20,3]: mismatched input 'else' expecting 'end'

Change those, save .rules file, no errors.

Stop, then restart openhab, watching logs at startup… no errors.

Press button… light comes on!

Thanks guise! :smiley: