[SOLVED] Openhab 2.5 new rules are not working

  • Platform information:
    • Hardware: RPi3b+
    • Java Runtime Environment: openjdk version “1.8.0_242”
      OpenJDK Runtime Environment (Zulu 8.44.0.11-CA-linux64) (build 1.8.0_242-b20)
      OpenJDK 64-Bit Server VM (Zulu 8.44.0.11-CA-linux64) (build 25.242-b20, mixed mode)
    • openHAB version: 2.5.1-2 (with MQTT1.0 Binding)
  • Issue of the topic: I created a new rule for my garage opener, but it is not working. I only see an error message. Any idea? Thanks for your support!

mqtt.items
String Button_Tradfri_1 { mqtt="<[mosquitto:zigbee2mqtt/0xccccccfffee267bf:state:default]" }
Status can be “on” or “off”
Number Tasmota_Garage_Distance “Entfernung [%.0f cm]” { mqtt="<[mosquitto:tele/sonoff_sensor_1/SENSOR:state:JSONPATH($.SR04.Distance)]" }

garage.rules
Line1: rule “Garage Schalter Wohnung Tradfri”
Line2: when
Line3: Item Button_Tradfri_1 changed
Line4: then
Line5:
Line6: if (Button_Tradfri_1.state == “on” && Tasmota_Garage_Distance.state > 250) {Sonoff_Basic_GA.sendCommand(ON)}
Line7: if (Button_Tradfri_1.state == “off” && Tasmota_Garage_Distance.state < 251) {Sonoff_Basic_GA.sendCommand(OFF)}
Line8: end

ERROR MESSAGE IN LOGFILE
2020-02-09 13:17:08.403 [ERROR] [xbase.resource.BatchLinkableResource] - resolution of uriFragment ‘|::0.2.0.2.0.0.0.6.6.6::0::/1’ failed.

java.lang.NullPointerException: null

2020-02-09 13:17:08.408 [ERROR] [xbase.resource.BatchLinkableResource] - resolution of uriFragment ‘|::0.2.0.2.0.0.0.6.6.6::0::/1’ failed.

java.lang.NullPointerException: null

2020-02-09 13:17:08.412 [ERROR] [xbase.resource.BatchLinkableResource] - resolution of uriFragment ‘|::0.2.0.2.0.0.0.6.6.6::0::/1’ failed.

java.lang.NullPointerException: null

2020-02-09 13:17:08.413 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘Garage Schalter Wohnung Tradfri’: The name ‘Button_Tradfri_1’ cannot be resolved to an item or type; line 6, column 13, length 16

Is this all you have in the .rules file and how are you defining your Items?

FYI… #12How to ask a good question / Help Us Help You

1 Like

No, the items are in the mqtt.items file and the rules are defined in garage.rules
There are a lot more items in the mqtt.items file, but I think this is not needed, nor?

I was curious about anything above this rule in the .rules file. The last error says line 6, but I don’t see Button_Tradfri_1 in line 6, so I assume something else is in the file. The other errors usually mean there is something in the file that is not an import, a global variable, or a rule.

Line 6 is if (Button_Tradfri_1.state == “on” && Tasmota_Garage_Distance.state > 250) {Sonoff_Basic_GA.sendCommand(ON)}

OK… code fences would have helped :wink:

Do you have Button_Tradfri_1 in a sitemap, and if so, does it work properly? Is the Thing online? Make a change to your Items file (or touch it) and watch the openhab.log for errors.

Try to change Line 6 to

Line 6 is if (Button_Tradfri_1.state == ON && Tasmota_Garage_Distance.state > 250) {Sonoff_Basic_GA.sendCommand(ON)}

not “on” but ON

The definition of Button_Tradfri_1 is as a String not Switch (look in OP).

Does your xxx.items file actually load? There will be a message in openhab.log

Yes it’s loading without error.

How about the other questions that I asked?

So, it’s not used in a sitemap. I added it and the value is correct (“on”/“off”).
I use MQTT1.0 Binding, therefore there is no THING for that, right? If you mean the MQTT Broker, it’s online, yes.
Items File can be changed without any error.

Correct

Do these errors come up every time you save the .rule file?

Everytime I save the rules-file or press the Tradfri-Button. I now made a update/upgrade and rebooted my Pi again… waiting for coming up again

The restart may help. If you cleared the cache, restart OH again once it comes up, which could be what had caused the issue.

Do you have other rules that access Items and do they run OK?

Very strange… after restart, same issue - clearing the cache, restarting again solved the issue.
All other rules worked fine and could be changed without any issue… Nevertheless now it’s working.
Thanks for your support.

Hey Guys,

i think ive got the same/similar issue but clearing cache and restart didnt help yet.

With every new rule or new rule content i get resolution of uriFragment - NullPointerException
If i delete new rules or new rule content, everything is fine again - even the old rules

I had to make a clean install - now it works again