[SOLVED] MQTT items stopped working

  • Platform information:
    • Hardware: Intel NUC 8GB /128GB SSD
    • OS: Ubuntu Server 16.04
    • Java Runtime Environment:OpenJDK Zulu
    • openHAB version:2.20 with Openhabian 1.4

This items file was working fine until recently:

Number OilDepth "Depth [%d cm]" (g1) { mqtt="<[broker:RTL_433/JSON:state:JSONPATH($.depth):.*\"id\" \\: 137574874,.*]"}
Number OilTemp "Oil Temperature [%.2f °C]" (g1) { mqtt="<[broker:RTL_433/JSON:state:JSONPATH($.temperature_C):.*\"id\" \\: 137574874,.*]"}
Number PowerMeter "Power [%d W]" (g1) { mqtt="<[broker:RTL_433/JSON:state:JSONPATH($.power0):.*\"dev_id\" \\: 77,.*]"}

It capures the topics generated by a power consumption meter and an Oil depth gauge. The MQTT topic looks like this:

{"time" : "2018-01-23 18:48:16", "model" : "CurrentCost TX", "dev_id" : 77, "power0" : 1490, "power1" : 0, "power2" : 0}
{"time" : "2018-01-23 18:48:18", "model" : "Oil Watchman", "id" : 137574874, "flags" : 128, "maybetemp" : 25, "temperature_C" : 6.667, "binding_countdown" : 0, "depth" : 31}
{"time" : "2018-01-23 18:48:22", "model" : "CurrentCost TX", "dev_id" : 77, "power0" : 1502, "power1" : 0, "power2" : 0}

mqtt.cfg:

broker.url=tcp://127.0.0.1:1883
broker.clientId=openHAB2

It was working and I could see values being recorded in the logs, but I can’t figure out why it stopped.
If I save the items file, I can see it reloading but still no values recorded:

2018-01-23 17:01:13.254 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'mqtt.items'

2018-01-23 17:01:13.265 [DEBUG] [.internal.MqttGenericBindingProvider] - Removing message consumers for item OilDepth

2018-01-23 17:01:13.275 [DEBUG] [.internal.MqttGenericBindingProvider] - Removing message publishers for item OilDepth

2018-01-23 17:01:13.286 [DEBUG] [.internal.MqttGenericBindingProvider] - Removing message consumers for item OilTemp

2018-01-23 17:01:13.297 [DEBUG] [.internal.MqttGenericBindingProvider] - Removing message publishers for item OilTemp

2018-01-23 17:01:13.308 [DEBUG] [.internal.MqttGenericBindingProvider] - Removing message consumers for item PowerMeter

2018-01-23 17:01:13.319 [DEBUG] [.internal.MqttGenericBindingProvider] - Removing message publishers for item PowerMeter

2018-01-23 17:01:13.331 [DEBUG] [binding.mqtt.internal.MqttItemConfig] - Loaded MQTT config for item 'OilDepth' : 1 subscribers, 0 publishers

2018-01-23 17:01:13.344 [DEBUG] [binding.mqtt.internal.MqttItemConfig] - Loaded MQTT config for item 'OilTemp' : 1 subscribers, 0 publishers

2018-01-23 17:01:13.357 [DEBUG] [binding.mqtt.internal.MqttItemConfig] - Loaded MQTT config for item 'PowerMeter' : 1 subscribers, 0 publishers

I have stopped OpenHAB and cleared the cache, as well as uninstalling and re-installing the MQTT binding, I enabled DEBUG logging on the binding but it also showed nothing.
Any ideas would be most welcome!

are it just those items that dont work or is your entire MQTT not working?
Did you recently upgrade?

I have had something similar recently and odly my MQTT binding only started working again after i reinstalled both the MQTT binding AND the MQTT action

1 Like

That’s all I have in the items file. Just now I added this to try to debug it some more:

String MQTT_Uptime “MQTT Uptime [%s]” {mqtt="<[broker:$SYS/broker/uptime:state:default]"}

It should create a log entry every few seconds, but still nothing after it loads the items file.

As a test, I copied the items file over to a Windows install of OH 2.2 and pointed mqtt.cfg at the same mosquitto server, and I can see the entries being recorded in the logs.

Hey, @Kees_van_Gelder, many thanks it was the MQTT action binding that was causing the problem. Reinstalling it fixed the problem.

1 Like

Great that that fixed it for you. I already had a hunch that was the problem

I seem to have the same problem (upgrade of OH), and already re-installed the binding. I never had the action installed though. I see absolutely no messages in my log anymore. Tested the broker with mqtt-spy and it worked, but openhab seems like it doesnt subscribe or connect to the broker anymore.

As i have no errors to work with - what can i do?

edit: installed the mqtt action for good measure, but i cant publish anything with it.

edit2: re-installing the binding, restarting OH and restarting the Access Point did nothing, but restarting the devices that work with MQTT changed something. Now i get updates via MQTT in OH again (still no log entrys like prior to the OH upgrade though). Will report if i stumble across anything else.