After an apparently random amount of time (hours-days), Openhab appears to stop updating a specific Thing channel that uses JSONPATH
###############################################################################
## Release = Raspbian GNU/Linux 11 (bullseye)
## Kernel = Linux 5.15.61-v7l+
## Platform = Raspberry Pi 4 Model B Rev 1.5
## Uptime = 21 day(s). 19:20:3
## CPU Usage = 1.51% avg over 4 cpu(s) (4 core(s) x 1 socket(s))
## CPU Load = 1m: 0.08, 5m: 0.07, 15m: 0.07
## Memory = Free: 0.13GB (7%), Used: 1.74GB (93%), Total: 1.87GB
## Swap = Free: 2.85GB (99%), Used: 0.03GB (1%), Total: 2.89GB
## Root = Free: 1.89GB (28%), Used: 4.80GB (72%), Total: 7.01GB
## Updates = 131 apt updates available.
## Sessions = 1 session(s)
## Processes = 140 running processes of 32768 maximum processes
###############################################################################
openHAB 3.3.0 - Release Build
openjdk version “11.0.16” 2022-07-19
OpenJDK Runtime Environment (build 11.0.16+8-post-Raspbian-1deb11u1)
OpenJDK Server VM (build 11.0.16+8-post-Raspbian-1deb11u1, mixed mode)
mosquitto version 2.0.11
I have a weight sensor that measures the weight of my Water Softener in order to calculate how much salt is present.
The weight sensor connects to wifi and sends a JSON to an MQTT topic.
An MQTT Thing creates channels that are linked to Items.
Example JSON - { “IPaddress”:“192.168.1.231”, “SSID”:“Wedding2”, “RSSI”:52, “Salt”:51.0 }
The Items, after some time, stop being updated.
Using an MQTT tool, I can see the JSON is still being published.
Restarting the openhab.service gets it working again.
I modified the Weight Sensor to publish the JSON and a discrete number to a different topic.
With an extra Thing channel and extra Item I get both JSON Weight and Discrete Weight.
Persisted them to an Influx database - graphed with Grafana.
Now I can see the exact time the JSON weight stopped being updated.
With the exact time, I wade through the log files looking for errors or warnings or something strange.
Nothing!
Below is the Thing file.
The same Thing has a channel for the JSON weight and a channel for discrete weight.
The only difference is that one uses JSONPATH and the other doesn’t. So I assume it is JSONPATH that has failed.
What can I do to discover why JSONPATH stops?
For the weight sensor, I have side stepped the problem with the discrete value because I also own the code in the sensor. Without a root cause analysis, I’m concerned that JSONPATH may stop for a sensor where I can’t change the MQTT publishing. e.g. a Shelly switch or Tasmota socket!
I have many sensors that publish JSONs without issue.
The chart belows shows discrete weight in Green and JSON weight in Yellow. At the start JSONPATH is failed. Then an OpenHab restart. Then a few days later, JSONPATH failure.
The two lines should track exactly together
// Water Softener Scales
Thing mqtt:topic:waterSoftener "Water Softener 2 MQTT" (mqtt:broker:MyMqttBroker) {
Channels:
Type number : saltJSON "Weight JSON" [
stateTopic="waterSoftener/status",
transformationPattern="JSONPATH:$.Salt",
postCommand=true // Sends a command as well as an update
]
Type number : salt "Weight" [
stateTopic="waterSoftener/weight",
postCommand=true // Sends a command as well as an update
]
Type string : weightSSID "SSID" [
stateTopic="waterSoftener/status",
transformationPattern="JSONPATH:$.SSID"
]
Type number : weightRSSI "RSSI" [
stateTopic="waterSoftener/status",
transformationPattern="JSONPATH:$.RSSI",
postCommand=true // Sends a command as well as an update
]
Type string : weightAddress "IP Address" [
stateTopic="waterSoftener/status",
transformationPattern="JSONPATH:$.IPaddress"
]
Type string : debug "Debug Message" [
stateTopic="waterSoftener/debug"
]
}