MQTT inbound

Hi folks,

i got a problem with my mqtt… ok.

  1. Mosquitto is running and the exampe:
Switch MQTT_Switch_Command  "MQTT Command"      {mqtt=">[mosquitto:Haus/EG/WZ/Licht:command:ON:LichtAn],>[mosquitto:Haus/EG/WZ/Licht:command:OFF:LichtAus]"}
String MQTT_Switch_State    "MQTT State [%s]" 	{mqtt="<[mosquitto:Haus/EG/WZ/Licht:state:default]"}

works!

The mqtt.conf is fine.

Now, my ESP8266 is sending temperature and humidity via WiFi + MQTT to mosquitto. I checked it with MQTT.fx. I can subscribe following topic:

Haus/Keller/Vorratsraum

and see the needed data.

Now i created following items

Number KellerTemp           {mqtt="<[mosquitto:Haus/Keller/Vorratsraum:state:JSONPATH($.temperature)]"}
String KellerHum            {mqtt="<[mosquitto:Haus/Keller/Vorratsraum:state:JSONPATH($.humidity)]"}

The JSON looks like:

{"temperature":24.80,"humidity":38.00}

I tried Number and String for the data… not even in the log-file, the items don’t get updated.

I don’t understand it…

have you installed the PaperUI → Add-ons → Transformations → JSONPath Transformation ?

Yes I did.

The problem is that the item doesn’t even receive any data.

I tried

String KellerHum            {mqtt="<[mosquitto:Haus/Keller/Vorratsraum:state:default]"}

to get

{"temperature":24.80,"humidity":38.00}

so, it is not a JSONPATH-Binding-problem.

Is that the complete JSON which you receive via MQTT?

The big problem: I don’t receive this JSON via MQTT.

But I know the broker works (checked with MQTT.fx) and OH2 MQTT-Binding seems to be configured in the right way (the MQTT example works, in OH2 and MQTT.fx).

I don’t care how you received it, the interesting point is the complete syntax of it.
I’m using Tasmota on a Sonoff switch, for getting temp and humidity I need to use something like …/Sensor:state…

please set the log level of the mqtt to trace!
add this to your org.ops4j.pax.logging.cfg in /var/lib/openhab2/etc

log4j2.logger.mqtt1.name = org.openhab.binding.mqtt
log4j2.logger.mqtt1.level = TRACE
log4j2.logger.mqtt2.name = org.openhab.io.transport.mqtt
log4j2.logger.mqtt2.level = TRACE

or use Karaf console
https://docs.openhab.org/administration/logging.html1

Did you by any change change the settings in mqtt.cfg without a restart? The new values are only set after restarting.

Maybe this will help:

2018-03-11 17:34:30.933 [DEBUG] [ng.mqtt.internal.MqttEventBusBinding] - MQTT: Activating event bus binding.

2018-03-11 17:34:30.938 [DEBUG] [org.openhab.binding.mqtt            ] - ServiceEvent REGISTERED - {org.osgi.service.event.EventHandler, org.osgi.service.cm.ManagedService}={event.topics=openhab/*, service.pid=org.openhab.mqtt-eventbus, component.name=org.openhab.binding.mqtt.eventbus, component.id=212, service.id=340, service.bundleid=224, service.scope=bundle} - org.openhab.binding.mqtt

2018-03-11 17:34:30.953 [TRACE] [ng.mqtt.internal.MqttEventBusBinding] - No mqtt-eventbus properties configured.

2018-03-11 17:34:30.961 [DEBUG] [org.openhab.binding.mqtt            ] - BundleEvent STARTED - org.openhab.binding.mqtt

Is this the problem “event.topics=openhab/*” ? And, where can I change it?

Maybe delete your mqtt.cfg, uninstall the binding. And start over again.

To get us into the problem you have to describe everything you do.
What is your setting? what do you type in ther terminal to get the data how does the result look like?
All depended file contents, items mqtt.cfg and a detailed explanation how you set it up.
Otherwise it is just guessing?

Maybe also a log containing all info from startup, with the logging level set as described above.

I have the lates beta of the binding so my output contains more data but somthing like this should be found in the log.

[TRACE] [openhab.io.transport.mqtt.MqttService] - Processing property: mymosquitto.pwd = Testing
[TRACE] [openhab.io.transport.mqtt.MqttService] - Processing property: mymosquitto.url = tcp://localhost:1883
[DEBUG] [rt.mqtt.internal.MqttBrokerConnection] - Closing connection to broker 'mymosquitto'
[TRACE] [openhab.io.transport.mqtt.MqttService] - Processing property: mymosquitto.user = Openhab
[INFO ] [openhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
[INFO ] [rt.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'mymosquitto'
[DEBUG] [rt.mqtt.internal.MqttBrokerConnection] - Creating new client for 'tcp://localhost:1883' using id 'paho64146399869' and file store '/var/lib/openhab2/tmp/mymosquitto'

Ok, uninstalled, installed, restarted OH2. Here is the log:

2018-03-12 19:34:43.063 [DEBUG] [org.openhab.io.transport.mqtt       ] - BundleEvent [unknown:512] - org.openhab.io.transport.mqtt

2018-03-12 19:35:09.112 [DEBUG] [org.openhab.io.transport.mqtt       ] - BundleEvent STARTING - org.openhab.io.transport.mqtt

2018-03-12 19:35:09.119 [DEBUG] [org.openhab.io.transport.mqtt       ] - BundleEvent STARTED - org.openhab.io.transport.mqtt

2018-03-12 19:35:09.136 [DEBUG] [penhab.io.transport.mqtt.MqttService] - Starting MQTT Service...

2018-03-12 19:35:09.141 [DEBUG] [org.openhab.io.transport.mqtt       ] - ServiceEvent REGISTERED - {org.openhab.io.transport.mqtt.MqttService, org.osgi.service.cm.ManagedService}={service.pid=org.openhab.mqtt, component.name=MQTT Connection Service, component.id=20, service.id=327, service.bundleid=232, service.scope=bundle} - org.openhab.io.transport.mqtt

2018-03-12 19:35:09.143 [TRACE] [penhab.io.transport.mqtt.MqttService] - Processing property: mosquitto.pwd = anadg999

2018-03-12 19:35:09.157 [TRACE] [penhab.io.transport.mqtt.MqttService] - Processing property: mosquitto.url = tcp://localhost:1883

2018-03-12 19:35:09.159 [TRACE] [penhab.io.transport.mqtt.MqttService] - Processing property: mosquitto.user = openhabian

2018-03-12 19:35:09.173 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.

2018-03-12 19:35:09.179 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'mosquitto'

2018-03-12 19:35:09.346 [DEBUG] [t.mqtt.internal.MqttBrokerConnection] - Creating new client for 'tcp://localhost:1883' using id 'paho186136566397949' and file store '/var/lib/openhab2/tmp/mosquitto'

2018-03-12 19:35:11.107 [DEBUG] [org.openhab.binding.mqtt            ] - BundleEvent STARTING - org.openhab.binding.mqtt

2018-03-12 19:35:11.115 [DEBUG] [.binding.mqtt.internal.MqttActivator] - MQTT binding has been started.

2018-03-12 19:35:11.133 [DEBUG] [org.openhab.binding.mqtt            ] - BundleEvent STARTED - org.openhab.binding.mqtt

2018-03-12 19:35:11.212 [TRACE] [.internal.MqttGenericBindingProvider] - Starting to load MQTT config for item MQTT_Switch_Command

2018-03-12 19:35:11.232 [DEBUG] [binding.mqtt.internal.MqttItemConfig] - Loaded MQTT config for item 'MQTT_Switch_Command' : 0 subscribers, 2 publishers

2018-03-12 19:35:11.264 [TRACE] [t.mqtt.internal.MqttBrokerConnection] - Starting message producer for broker 'mosquitto'

2018-03-12 19:35:11.269 [TRACE] [t.mqtt.internal.MqttBrokerConnection] - Starting message producer for broker 'mosquitto'

2018-03-12 19:35:11.281 [TRACE] [.internal.MqttGenericBindingProvider] - Starting to load MQTT config for item MQTT_Switch_State

2018-03-12 19:35:11.290 [DEBUG] [binding.mqtt.internal.MqttItemConfig] - Loaded MQTT config for item 'MQTT_Switch_State' : 1 subscribers, 0 publishers

2018-03-12 19:35:11.295 [DEBUG] [t.mqtt.internal.MqttBrokerConnection] - Starting message consumer for broker 'mosquitto' on topic 'Haus/EG/WZ/Licht'

2018-03-12 19:35:11.364 [TRACE] [.internal.MqttGenericBindingProvider] - Starting to load MQTT config for item KellerTemp

2018-03-12 19:35:11.382 [DEBUG] [binding.mqtt.internal.MqttItemConfig] - Loaded MQTT config for item 'KellerTemp' : 1 subscribers, 0 publishers

2018-03-12 19:35:11.389 [DEBUG] [t.mqtt.internal.MqttBrokerConnection] - Starting message consumer for broker 'mosquitto' on topic 'Haus/Keller/Vorratsraum'

2018-03-12 19:35:11.401 [TRACE] [.internal.MqttGenericBindingProvider] - Starting to load MQTT config for item KellerHum

2018-03-12 19:35:11.409 [DEBUG] [binding.mqtt.internal.MqttItemConfig] - Loaded MQTT config for item 'KellerHum' : 1 subscribers, 0 publishers

2018-03-12 19:35:11.418 [DEBUG] [t.mqtt.internal.MqttBrokerConnection] - Starting message consumer for broker 'mosquitto' on topic 'Haus/Keller/Vorratsraum'

2018-03-12 19:35:11.508 [TRACE] [.internal.MqttGenericBindingProvider] - Starting to load MQTT config for item maxActual_bad

2018-03-12 19:35:11.512 [DEBUG] [binding.mqtt.internal.MqttItemConfig] - Loaded MQTT config for item 'maxActual_bad' : 0 subscribers, 1 publishers

2018-03-12 19:35:11.517 [TRACE] [t.mqtt.internal.MqttBrokerConnection] - Starting message producer for broker 'mosquitto'

2018-03-12 19:35:11.537 [DEBUG] [org.openhab.binding.mqtt            ] - ServiceEvent REGISTERED - {org.osgi.service.event.EventHandler}={event.topics=openhab/*, component.name=org.openhab.binding.mqtt.MqttItemBinding, component.id=210, service.id=339, service.bundleid=231, service.scope=bundle} - org.openhab.binding.mqtt

2018-03-12 19:35:11.544 [DEBUG] [org.openhab.binding.mqtt            ] - ServiceEvent REGISTERED - {org.openhab.model.item.binding.BindingConfigReader, org.openhab.binding.mqtt.MqttBindingProvider}={component.name=org.openhab.binding.mqtt.genericbindingprovider, component.id=211, service.id=337, service.bundleid=231, service.scope=bundle} - org.openhab.binding.mqtt

2018-03-12 19:35:11.633 [DEBUG] [ng.mqtt.internal.MqttEventBusBinding] - MQTT: Activating event bus binding.

2018-03-12 19:35:11.653 [TRACE] [ng.mqtt.internal.MqttEventBusBinding] - No mqtt-eventbus properties configured.

2018-03-12 19:35:11.656 [DEBUG] [org.openhab.binding.mqtt            ] - ServiceEvent REGISTERED - {org.osgi.service.event.EventHandler, org.osgi.service.cm.ManagedService}={event.topics=openhab/*, service.pid=org.openhab.mqtt-eventbus, component.name=org.openhab.binding.mqtt.eventbus, component.id=212, service.id=340, service.bundleid=231, service.scope=bundle} - org.openhab.binding.mqtt

Mosquitto is running. Example in the first post is working. I checked also with MQTT.fx

Was the problem solved then?
Example is working means your ESP8266 JSON gets updated?