[SOLVED] Failing getting Data via mqtt binding

I don’t get my setting running and don’t see my probably stupid misstake
my setting is 3 Docker Containers koenkk/zigbee2mqtt, eclipse-mosquitto:latest and openhab/openhab:latest.

with MQTT.fx i can see my devices e.g.
zigbee2mqtt/WoZiTempSens
with following payload
{
“humidity” : 43.39,
“linkquality” : 55,
“battery” : 96,
“voltage” : 2900,
“temperature” : 21.53
}

according to this i create follow .things file

Bridge  mqtt:broker:mosquitto "Mosquitto" [ host="192.168.178.63", secure=false, clientID="openHAB2"  ]
{
    Thing topic WoZiSens "Living Room Light" @ "Living Room" {
    Channels:
        Type number : temperature "Temperature"   [ stateTopic="zigbee2mqtt/WoZiTempSens", transformationPattern="JSONPATH:$.SI7021.temperature" ]
        Type number : humidity    "Humidity"      [ stateTopic="zigbee2mqtt/WoZiTempSens", transformationPattern="JSONPATH:$.SI7021.humidity" ]
    }
}

and items-file

Number WoZi_temperature "Temperatur Wohnzimmer [%.0f °C]" <temp> { channel="mqtt:broker:mosquitto:WoZiSens:temperature" }

on my Test page i get no value what i did wrong?

edit: in the log files of mqtt i can see the login of my openHAB2 and the openHAB log say the that broker is online

Did you check with PaperUI that the channel setting of your item matches the channel dilated on PaperUI ?

Your transformation patterns are incorrect according to the payload supplied:

transformationPattern="JSONPATH:$.SI7021.temperature"

Payload:

{
“humidity” : 43.39,
“linkquality” : 55,
“battery” : 96,
“voltage” : 2900,
“temperature” : 21.53
}

The tranformation pattern should be:

transformationPattern="JSONPATH:$.temperature"

Where the SI7021 came from is left to imagination…

1 Like

@vzorglub
this was just ja test a found in a other example but in before i tested

Type number : temperature "Temperature"   [ stateTopic="zigbee2mqtt/WoZiTempSens", transformationPattern="JSONPATH:$.temperature" ]

but i did get any information on my test side

@opus
i configure everything via config files and don’t see this in the paper ui?

Even if all setup is done via config files you will see the things and their channels on PaperUI! Having it done all correctly, the items would show as linked to the channel although in your case that migth be not the case. Look at the correct channel syntax as displayed on PaperUI and compare it with the used one in your items file.

if i scan in paper ui for things of the mqtt binding nothing is shown i can just add it manually so it looks like the connection doesn’t work?
I found in the openhab log following in event.log

2019-11-01 18:29:22.212 [hingStatusInfoChangedEvent] - 'mqtt:topic:mosquitto:WoZiSens' changed from ONLINE to UNINITIALIZED
2019-11-01 18:29:22.226 [hingStatusInfoChangedEvent] - 'mqtt:broker:mosquitto' changed from ONLINE to UNINITIALIZED
2019-11-01 18:29:22.239 [hingStatusInfoChangedEvent] - 'mqtt:broker:mosquitto' changed from UNINITIALIZED to OFFLINE
2019-11-01 18:29:22.244 [hingStatusInfoChangedEvent] - 'mqtt:broker:mosquitto' changed from OFFLINE to UNINITIALIZED (HANDLER_MISSING_ERROR)
2019-11-01 18:29:22.247 [hingStatusInfoChangedEvent] - 'mqtt:topic:mosquitto:WoZiSens' changed from UNINITIALIZED to UNINITIALIZED (HANDLER_MISSING_ERROR)
2019-11-01 18:29:22.306 [hingStatusInfoChangedEvent] - 'mqtt:broker:mosquitto' changed from UNINITIALIZED to INITIALIZING
2019-11-01 18:29:22.311 [hingStatusInfoChangedEvent] - 'mqtt:broker:mosquitto' changed from INITIALIZING to OFFLINE
2019-11-01 18:29:22.317 [hingStatusInfoChangedEvent] - 'mqtt:topic:mosquitto:WoZiSens' changed from UNINITIALIZED to INITIALIZING
2019-11-01 18:29:22.325 [hingStatusInfoChangedEvent] - 'mqtt:topic:mosquitto:WoZiSens' changed from INITIALIZING to OFFLINE (BRIDGE_OFFLINE)
2019-11-01 18:29:22.335 [hingStatusInfoChangedEvent] - 'mqtt:broker:mosquitto' changed from OFFLINE to ONLINE
2019-11-01 18:29:22.338 [hingStatusInfoChangedEvent] - 'mqtt:topic:mosquitto:WoZiSens' changed from OFFLINE (BRIDGE_OFFLINE) to ONLINE
2019-11-01 18:33:51.997 [hingStatusInfoChangedEvent] - 'mqtt:topic:mosquitto:WoZiSens' changed from ONLINE to UNINITIALIZED
2019-11-01 18:33:52.006 [hingStatusInfoChangedEvent] - 'mqtt:broker:mosquitto' changed from ONLINE to UNINITIALIZED
2019-11-01 18:33:52.017 [hingStatusInfoChangedEvent] - 'mqtt:broker:mosquitto' changed from UNINITIALIZED to OFFLINE
2019-11-01 18:33:52.026 [hingStatusInfoChangedEvent] - 'mqtt:broker:mosquitto' changed from OFFLINE to UNINITIALIZED (HANDLER_MISSING_ERROR)
2019-11-01 18:33:52.036 [hingStatusInfoChangedEvent] - 'mqtt:topic:mosquitto:WoZiSens' changed from UNINITIALIZED to UNINITIALIZED (HANDLER_MISSING_ERROR)
2019-11-01 18:33:52.038 [hingStatusInfoChangedEvent] - 'mqtt:broker:mosquitto' changed from UNINITIALIZED to INITIALIZING
2019-11-01 18:33:52.040 [hingStatusInfoChangedEvent] - 'mqtt:broker:mosquitto' changed from INITIALIZING to OFFLINE
2019-11-01 18:33:52.043 [hingStatusInfoChangedEvent] - 'mqtt:topic:mosquitto:WoZiSens' changed from UNINITIALIZED to INITIALIZING
2019-11-01 18:33:52.046 [hingStatusInfoChangedEvent] - 'mqtt:topic:mosquitto:WoZiSens' changed from INITIALIZING to OFFLINE (BRIDGE_OFFLINE)
2019-11-01 18:33:52.073 [hingStatusInfoChangedEvent] - 'mqtt:broker:mosquitto' changed from OFFLINE to ONLINE
2019-11-01 18:33:52.078 [hingStatusInfoChangedEvent] - 'mqtt:topic:mosquitto:WoZiSens' changed from OFFLINE (BRIDGE_OFFLINE) to ONLINE

in openhab.log

2019-11-01 18:33:51.997 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'Runnable.run()' on 'org.eclipse.smarthome.core.thing.internal.ThingManagerImpl$$Lambda$582/1899379718@2be55009': org.eclipse.smarthome.binding.mqtt.generic.internal.handler.GenericThingHandler cannot be cast to org.eclipse.smarthome.binding.mqtt.handler.AbstractBrokerHandler
java.lang.ClassCastException: org.eclipse.smarthome.binding.mqtt.generic.internal.handler.GenericThingHandler cannot be cast to org.eclipse.smarthome.binding.mqtt.handler.AbstractBrokerHandler
	at org.eclipse.smarthome.binding.mqtt.internal.MqttBrokerHandlerFactory.lambda$0(MqttBrokerHandlerFactory.java:83) ~[?:?]
	at java.util.WeakHashMap.forEach(WeakHashMap.java:1025) ~[?:?]
	at java.util.Collections$SynchronizedMap.forEach(Collections.java:2649) ~[?:?]
	at org.eclipse.smarthome.binding.mqtt.internal.MqttBrokerHandlerFactory.removeHandler(MqttBrokerHandlerFactory.java:83) ~[?:?]
	at org.eclipse.smarthome.core.thing.binding.BaseThingHandlerFactory.unregisterHandler(BaseThingHandlerFactory.java:261) ~[?:?]
	at org.eclipse.smarthome.core.thing.internal.ThingManagerImpl.lambda$5(ThingManagerImpl.java:811) ~[?:?]
	at sun.reflect.GeneratedMethodAccessor92.invoke(Unknown Source) ~[?:?]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
	at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:153) [102:org.eclipse.smarthome.core:0.10.0.oh240]
	at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:53) [102:org.eclipse.smarthome.core:0.10.0.oh240]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
	at java.lang.Thread.run(Thread.java:748) [?:?]
2019-11-01 18:33:52.032 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'mqtt.things'
2019-11-01 18:33:52.041 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to '192.168.178.63' with clientid openHAB2 and file store '/openhab/userdata/mqtt/192.168.178.63'
2019-11-01 18:33:53.051 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'mqtt.things'

mqtt say everything should be fine

1572629632: New connection from 192.168.178.63 on port 1883.
1572629632: New client connected from 192.168.178.63 as openHAB2 (p2, c1, k60).

That looks like a problem with the broker, do you have all client IDs different?

1 Like

That looks bang on

what client ID you mean?

The MQTT client ID
Each MQTT client connected to the broker MUST have a unique ID
When two clients have the same ID the ONLINE/OFFLINE… is a good symptom of that

I delete everything and try i via the PaperUI but i stuck again.
I add a broker and cofigure it and the broker thing says online
if i try to add a generic mqtt think the thing say online as well if i try to add an Channel i have problems again.
if but the setting as shown the generic mqtt think is immediately offline with the message Status: OFFLINE - COMMUNICATION_ERROR java.lang.Exception: No MQTT client

this event in event.log

2019-11-01 21:48:39.737 [hingStatusInfoChangedEvent] - 'mqtt:topic:WohnzimmerTemperature' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): java.lang.Exception: No MQTT client
2019-11-01 21:48:39.737 [me.event.ThingUpdatedEvent] - Thing 'mqtt:topic:WohnzimmerTemperature' has been updated.
2019-11-01 21:50:15.675 [hingStatusInfoChangedEvent] - 'mqtt:topic:WohnzimmerTemperature' changed from OFFLINE (COMMUNICATION_ERROR): java.lang.Exception: No MQTT client to ONLINE
2019-11-01 21:50:15.677 [me.event.ThingUpdatedEvent] - Thing 'mqtt:topic:WohnzimmerTemperature' has been updated.

in openhab.log no message appears so it seems like a wrong state expression :frowning:

Which ClientID did you set for the device you are trying to connect when it fails? You need to check that on the device or the webpage of it (do know anything about zigbee, sorry), not on openHAB!

i check the Client ID with MQTT.fx from there i use the name or i have to use the ID and not the friendlyname?

devices:
‘0x000d6ffffe65a048’:
friendly_name: ‘WoZiTempSens’
retain: false

or from zigbee2mqtt log
10/31/2019, 5:51:01 PM - info: MQTT publish: topic ‘zigbee2mqtt/WoZiTempSens’, payload ‘{“humidity”:43.11,“linkquality”:55,“battery”:96,“voltage”:2900,“temperature”:20.9}’

Okay now it gets really strange, i change nothing and now values are available :thinking: i don’t really get it-
The container gets restarted due to a update this night. Maybe the update fix a bug or the restart helped.