Rules with received update not working for me

Hi, I experienced an odd behavior with a rule. Because I need to do a calculation of an item I created a (textual) rule. In principle the value is pretty static so I am using “received update” and not “changed”. As you can see I also update a timestamp to see if my MQTT from an Arduino UNO is still alive. I noticed this timestamp was not updated, The later added loginfo does not generate a “org.openhab.core.model.script.rule”. When I check with MQTT explorer everything on the Arduino side works and new topics are sent. I also tested a start/stop of openhab; this will activate the rule (including the loginfo)

My rule is:

rule "waterlevel"
when
    //Time cron "0 0/5 * * * ?" or
    //Thing "mqtt:topic:NAP" received update or
	Item Cellar_pump received update
then
    var Number vNAP = Cellar_pump.state as DecimalType
    NAP_lastupdate.postUpdate(new DateTimeType())
    vNAP = 360 - 196 + 55 - vNAP
    if ( vNAP < 150 ) {
	    Cellar_pump_NAP.postUpdate(vNAP)
        logInfo("RULE", "Received waterlevel value : " + vNAP)
    } else {
        logInfo("RULE", "Waterlevel value incorrect : " + vNAP)
    }
end

What do I miss?

My details are:

Hardware: Intel NUC 7i3BNK - 12 Gb
system: Ubuntu 22.04.1 LTS (GNU/Linux 5.15.0-60docker veerr-generic x86_64)
openhab/openhab:3.4.1  (on docker)
wj4nuc@nuc:~$ docker version
Client: Docker Engine - Community
 Version:           20.10.23
 API version:       1.41
 Go version:        go1.18.10
 Git commit:        7155243
 Built:             Thu Jan 19 17:45:08 2023
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.23
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.18.10
  Git commit:       6051f14
  Built:            Thu Jan 19 17:42:57 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.15
  GitCommit:        5b842e528e99d4d4c1686467debf2bd4b88ecd86
 runc:
  Version:          1.1.4
  GitCommit:        v1.1.4-0-g5fd4c4d
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
# java -version
openjdk version "11.0.17" 2022-10-18
OpenJDK Runtime Environment Temurin-11.0.17+8 (build 11.0.17+8)
OpenJDK 64-Bit Server VM Temurin-11.0.17+8 (build 11.0.17+8, mixed mode)

Let’s see if we can confirm whether the MQTT binding is receiving the message and ignoring it or if the problem is with updating the Item or the rule ignoring the update.

There’s a number of ways to do this. If your Arduino publishes frequently, you can use the event stream on the Developer Sidebar in MainUI. Filter for the Item and watch it and your MQTT Explorer and see if the events are occurring. If so we can look to the rule. If not our focus is on the binding.

Alternatively, you can put the MQTT binding into trace level logging (which may need to be done anyway) and watch what it does when the Arduino publishes a message. You can now change the log level through MainUI. Navigate to Settings → Bindings → MQTT and click the little cog icon in the upper right. You can change the log level from there.

If it does turn out to be the binding, please post your Thing definition.

Side note: You can link the same Channel linked to Cellar_pump to NAP_lastupdate with the timestamp Profile and that will push capturing the timestamp outside the rule. That could be another way to determine if the problem is the rule triggering or the MQTT binding.

@rlkoshak thanks for your reply, based open your guidelines I was able to pinpoint this problem much better. Here are my findings:

In principle my Arduino UNO Sketch works “fine” however my callback function was partly shaky; a change request for the time_between_messages (=delay) works fine but a newly added temperature offset created the mess. It hangs the UNO and gives a warning on Openhab:

2023-02-14 11:38:38.252 [WARN ] [nding.mqtt.generic.ChannelStateTransformation] - 
Executing the MAP-transformation failed: Target value not found in map for ''

After I reset the UNO I now notice that in the Event Monitor the “single” messages are received in Openhab but the “combined transformation” message is not received anymore.

MQTT topics from MQTT explorer:

Result in Event Monitor:

image

The only way I found so far to get it working again (apart from a better sketch :grin:) is to do a stop/start of Openhab.

Conclusion: It was completely a self-inflicted error which Openhab did not like at all.