[Solved] MQTT with multiple JSON payloads, parsing help

Hi

I just bought a Sonoff Zigbee bridge that I flashed with Tasmota and sending the result of multiple sensors over MQTT to OpenHAB. I have several other devices configured and updating items with MQTT but they all have there own topic. I’m struggelning to parse out the date from the new Sonoff Bridge since all the connected sensors are under the same topic.

mosquitto_sub -h 192.168.1.xx -u mqttuser -P -t tele/tasmota_D9B354/STATE/#

tele/tasmota_D9B354/SENSOR {"ZbReceived":{"0xDB69":{"Device":"0xDB69","Name":" P1-Garage","0500<00":"010000000000","ZoneStatusChange":1,"Endpoint":1,"LinkQuality":66}}}
tele/tasmota_D9B354/SENSOR {"ZbReceived":{"0xDB69":{"Device":"0xDB69","Name":" P1-Garage","0500<00":"000000000000","ZoneStatusChange":0,"Endpoint":1,"LinkQuality":81}}}        
tele/tasmota_D9B354/SENSOR {"ZbReceived":{"0x72E3":{"Device":"0x72E3","Name":" P2-Backyard","0500<00":"010000000000","ZoneStatusChange":1,"Endpoint":1,"LinkQuality":76}}}
tele/tasmota_D9B354/SENSOR {"ZbReceived":{"0x2B77":{"Device":"0x2B77","Name":" P3w-Lekrum","0500<00":"000000000000","ZoneStatusChange":0,"Endpoint":1,"LinkQuality":60}}}

I tried with this to get out a given endpoint:

Number  Zigbee_P1_GarageDoor  "GarageDoor"  {mqtt="<[mosquitto:tele/tasmota_D9B354/SENSOR:state:JSONPATH($.ZbReceived[0x72E3].ZoneStatusChange)]"}

But its trowing parsing errors in the log:

org.openhab.core.transform.TransformationException: An error occurred while transforming JSON expression.
at org.openhab.core.transform.TransformationHelper$TransformationServiceDelegate.transform(TransformationHelper.java:71) ~[bundleFile:?]
at org.openhab.binding.mqtt.internal.MqttMessageSubscriber.processMessage(MqttMessageSubscriber.java:137) [bundleFile:?]
at org.openhab.io.transport.mqtt.internal.MqttBrokerConnection.messageArrived(MqttBrokerConnection.java:574) [bundleFile:?]
at org.eclipse.paho.client.mqttv3.internal.CommsCallback.deliverMessage(CommsCallback.java:475) [org.eclipse.paho.client.mqttv3-1.1.0.jar:?]
at org.eclipse.paho.client.mqttv3.internal.CommsCallback.handleMessage(CommsCallback.java:379) [org.eclipse.paho.client.mqttv3-1.1.0.jar:?]
at org.eclipse.paho.client.mqttv3.internal.CommsCallback.run(CommsCallback.java:183) [org.eclipse.paho.client.mqttv3-1.1.0.jar:?]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_232]

Please advice

Thanks!


A little closer to the solution, one item is updated but it throws MQTT errors in the log for all my other items so the parsing is not mathing the ID if the sensor and tries to update all the items…

Number  Zigbee_P1_GarageDoor  "GarageDoor"    {mqtt="<[mosquitto:tele/tasmota_D9B354/SENSOR:state:JSONPATH($.ZbReceived.0xDB69.ZoneStatusChange)]"}
Number  Zigbee_P1_FrontDoor   "FrontDoor"     {mqtt="<[mosquitto:tele/tasmota_D9B354/SENSOR:state:JSONPATH($.ZbReceived.0x76DB.ZoneStatusChange)]"}

Output of the logfile:

020-09-15 06:35:14.322 [vent.ItemStateChangedEvent] - Zigbee_P1_GarageDoor changed from 0 to 1
==> /var/log/openhab2/openhab.log <==
2020-09-15 06:35:16.414 [WARN ] [.mqtt.internal.MqttMessageSubscriber] - Error processing MQTT message.
org.openhab.core.transform.TransformationException: Invalid path ‘$.ZbReceived.0x76DB.ZoneStatusChange’ in ‘{“ZbReceived”:{“0xDB69”:{“Device”:“0xDB69”,“Name”:" P1-Garage",“0500<00”:“000000000000”,“ZoneStatusChange”:0,“Endpoint”:1,“LinkQuality”:63}}}’

at org.openhab.core.transform.TransformationHelper$TransformationServiceDelegate.transform(TransformationHelper.java:71) ~[bundleFile:?]

at org.openhab.binding.mqtt.internal.MqttMessageSubscriber.processMessage(MqttMessageSubscriber.java:137) [bundleFile:?]

at org.openhab.io.transport.mqtt.internal.MqttBrokerConnection.messageArrived(MqttBrokerConnection.java:574) [bundleFile:?]

at org.eclipse.paho.client.mqttv3.internal.CommsCallback.deliverMessage(CommsCallback.java:475) [org.eclipse.paho.client.mqttv3-1.1.0.jar:?]

at org.eclipse.paho.client.mqttv3.internal.CommsCallback.handleMessage(CommsCallback.java:379) [org.eclipse.paho.client.mqttv3-1.1.0.jar:?]

at org.eclipse.paho.client.mqttv3.internal.CommsCallback.run(CommsCallback.java:183) [org.eclipse.paho.client.mqttv3-1.1.0.jar:?]

at java.lang.Thread.run(Thread.java:748) [?:1.8.0_232]*

The error is probably coming from transform not finding the key 0x72E3 in the message. I would create a rule that catches all messages on tele/tasmota_D9B354/SENSOR and have it parse the message and either forward the actual device packet to a receiver item that does something with it, or within the the same rule have it update the items of the device.

To avoid writing specific code for each device you could compose item names along the lines of sensor_0x72E3_ZoneStatusChange and then have a loop that goes through all the different fields in the packet that you need information from for any of your devices and looks for an item matching the pattern sensor_{ID}_{FIELD} and updates/commands it if the item exists.

FYI this would be a lot easier to write in Jython rules if you’re using those. I can write you a Jython example later if you want, coding is not ideal on a phone.

1 Like

In tasmota console do SetOption4 1

This may give them their own topic

I did it on the console as recommended but it’s still sending only one topic for all the sensors:

08:20:38 CMD: SetOption4 1
08:20:38 SRC: WebConsole from 192.168.1.66
08:20:38 CMD: Group 0, Index 4, Command "SETOPTION", Data "1"
08:20:38 MQT: stat/tasmota_D9B354/SETOPTION = {"SetOption4":"ON"

MQTT on OpenHAB:

tele/tasmota_D9B354/SENSOR {"ZbReceived":{"0xDB69":{"Device":"0xDB69","Name":" P1-Garage","0500<00":"000000000000","ZoneStatusChange":0,"Endpoint":1,"LinkQuality":39}}}
tele/tasmota_D9B354/STATE {"Time":"2020-09-15T08:21:29","Uptime":"4T22:50:15","UptimeSec":427815,"Vcc":3.462,"Heap":26,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":1,"Wifi":{"AP":1,"SSId":"StarmanAP-Hosted","BSSId":"80:2A:A8:D4:14:C3","Channel":1,"RSSI":100,"Signal":-38,"LinkCount":1,"Downtime":"0T00:02:25"}}
tele/tasmota_D9B354/SENSOR {"ZbReceived":{"0xDB69":{"Device":"0xDB69","Name":" P1-Garage","0500<00":"010000000000","ZoneStatusChange":1,"Endpoint":1,"LinkQuality":81}}}
tele/tasmota_D9B354/SENSOR {"ZbReceived":{"0xDB69":{"Device":"0xDB69","Name":" P1-Garage","0500<00":"000000000000","ZoneStatusChange":0,"Endpoint":1,"LinkQuality":68}}}

Do I need to reboot or do any other changes on the Tasmota?

Another option: I would use REGEX to confirm that the JSON message includes the unique ID that I’m after, and then use JSONPath to extract the required data.

I use the V2 MQTT binding which makes this super easy, though I’m fairly sure you can do this with the V1 binding too, directly in the Item definition.

Hi

Whatever solves my problem would be fine :slight_smile:
Please provide an example when you got some spare time over. Thanks!

Searching this forum for “tasmota mqtt json” provides a lot of examples.
You should watch out for use of v1 or v2 binding syntax though.
https://community.openhab.org/search?q=tasmota%20mqtt%20json

1 Like

Ok so here is a working example for tasmota kettle :partying_face:

rule "Transform JSON to temp C"
when
    Item KettleInKitchenTuyarecieved changed 
then
    var temp = 0
    if (KettleInKitchenTuyarecieved.state.toString.contains('"DpId":5')) 
    { 
        logInfo("TuyaReceived", + KettleInKitchenTuyarecieved ) 
        var temp = transform("JSONPATH", "$.TuyaReceived.DpIdData", KettleInKitchenTuyarecieved.state)
        logInfo("HEX TEMP", + temp )
        //var temp = Integer.parseInt(hex_code, 16) as Number
        logInfo("Temp of kettle", + temp)
        Kettle_Temperature.postUpdate( temp )
        }
end

I don’t use the old Mqtt Binding so I have things like
Thing File

Bridge mqtt:broker:myMQTTBroker [ host="192.168.1.148", secure=false, username="please", password="work" , clientID="myMQTTClient" ]
{
 
    Thing topic D9B354 "D9B354 Tasmota" {
    Channels:
        Type string : sensor   "Zigbee Tasmota "  [ stateTopic="tele/tasmota_D9B354/SENSOR"]
        
      }
}

You only need to setup the broker once in any file or paper ui

Then item

String  Json_String_D9B354    {channel="mqtt:topic:myMQTTBroker:D9B354:sensor"}
Number  Zigbee_P1_GarageDoor  "GarageDoor"    
Number  Zigbee_P1_FrontDoor   "FrontDoor" 

The Json_String_D9B354 will change every time it recives a json string from tasmota.

Then to process that data into another item create a rule
Something like (not tested)

rule "Transform Json_String_D9B354"
when
    Item Json_String_D9B354 changed 
then
    var xDB69 = 0
    var x72E3 = 0
    if (Json_String_D9B354.state.toString.contains("0xDB69")) 
    { 
        logInfo("Received", + Json_String_D9B354 ) 
        xDB69 = transform("JSONPATH", "$.ZbReceived.0xDB69.ZoneStatusChange", Json_String_D9B354.state)
        Zigbee_P1_GarageDoor.postUpdate( xDB69 )
    }

    if (Json_String_D9B354.state.toString.contains("0x72E3")) 
    { 
        logInfo("Received", + Json_String_D9B354 ) 
        x72E3 = transform("JSONPATH", "$.ZbReceived.0x72E3.ZoneStatusChange", Json_String_D9B354.state)
        Zigbee_P1_FrontDoor.postUpdate( x72E3 )
    }

end

I use VScode remote dev to edit config file as my work flow

Hi,
I had the same issue with the MQTT1 binding, but I’m not sure, if you run into the same problem that I had.
In my case the “<” un the payload was the problem. Despite being allowed as a character in a JSON message, OpenHAB seemed to missinterpret the character and throwed an error.
I had to evaluate the whole JSON string in a rule.

Joerg

Thanks!

Did a minor tweek on the rule to get it working “state.toString”

rule "Transform Json_String_D9B354"

when
    Item Json_String_D9B354 changed
then
    if (Json_String_D9B354.state.toString.contains("0x7DB8"))
    {
        val x7DB8 = transform("JSONPATH", "$.ZbReceived.0x7DB8.ZoneStatusChange", Json_String_D9B354.state.toString)
        Zigbee_P1_GarageDoor.postUpdate( x7DB8 )
    }
    if (Json_String_D9B354.state.toString.contains("0x76DB"))
    {
        val x76DB = transform("JSONPATH", "$.ZbReceived.0x76DB.ZoneStatusChange", Json_String_D9B354.state.toString)
        Zigbee_P1_FrontDoor.postUpdate( x76DB )
    }
    if (Json_String_D9B354.state.toString.contains("0x72E3"))
    {
        val x72E3 = transform("JSONPATH", "$.ZbReceived.0x72E3.ZoneStatusChange", Json_String_D9B354.state.toString)
        Zigbee_P2_BackyardDoor.postUpdate( x72E3 )
    }
    if (Json_String_D9B354.state.toString.contains("0x76C2"))
    {
        val x76C2 = transform("JSONPATH", "$.ZbReceived.0x76C2.ZoneStatusChange", Json_String_D9B354.state.toString)
        Zigbee_P2_BalconyDoor.postUpdate( x76C2 )
    }
end

It’s possible to use Jame’s approach without the Rule. See MQTT 2.5 M1+ How to implement the equivalent to MQTT1 REGEX filters. It works by chaining a REGEX filter that looks for the string you care about (e.g. “0x7DB8”) and only if it’s present does the message get passed to the JSONPATH transform. Then you can create multiple channels for each device that get updated from the same MQTT topic and even from the same MQTT messages.

2 Likes

@rlkoshak I had forgotten about that!

@Michael_Stjerna you may find https://regexr.com/ useful when testing regular expressions, I know I do.

@rlkoshak allways comes up with the goods. I always look at his examples when I have problems and he has tought me heaps. I lerned a new thing today. It will come in very handy for my tasmota ir blaster.

So what this means is less code.

Thing file

Bridge mqtt:broker:myMQTTBroker [ host="192.168.1.148", secure=false, username="please", password="work" , clientID="myMQTTClient" ] //Only one bridge needed for all mqtt things
{
    Thing topic D9B354 "D9B354 Tasmota" {
    Channels:
        Type contact : Zigbee_P1_GarageDoor  "GarageDoor"  [ stateTopic="tele/tasmota_D9B354/SENSOR", transformationPattern="REGEX:(.*0xDB69.*)∩JSONPATH:$.ZbReceived.0xDB69.ZoneStatusChange", 0="open", 1="close" ]
        Type contact : Zigbee_P1_FrontDoor   "FrontDoor"   [ stateTopic="tele/tasmota_D9B354/SENSOR", transformationPattern="REGEX:(.*0x76DB.*)∩JSONPATH:$.ZbReceived.0x76DB.ZoneStatusChange", 0="open", 1="close" ]
      }

}

Item File

Contact   D9B354TasmotaZigbeeP1GarageDoor   "Garage door"   {channel="mqtt:topic:myMQTTBroker:D9B354:Zigbee_P1_GarageDoor"}
Contact   D9B354TasmotaZigbeeP1FrontDoor    "Front door"    {channel="mqtt:topic:myMQTTBroker:D9B354:Zigbee_P1_FrontDoor"}

This will give you OPEN and CLOSED states for you items.

[vent.ItemStateChangedEvent] - ZigbeeP1FrontDoor changed from OPEN to CLOSED

Can I have both the new and legacy broker installed at the same time?

MQTT Binding

binding-mqtt - 2.5.8.SNAPSHOT

MQTT Binding (1.x)

binding-mqtt1 - 1.14.0

When I try to install the new 2.5.8 binding i get this thrown in the log:

2020-09-16 06:55:19.539 [ERROR] [org.openhab.binding.mqtt ] - bundle org.openhab.binding.mqtt:2.5.8.202008170654 (339)[org.openhab.binding.mqtt.internal.MqttBrokerHandlerFactory(544)] : Error during instantiation of the implementation object

java.lang.NoClassDefFoundError: org/openhab/binding/mqtt/MqttBindingConstants

at org.openhab.binding.mqtt.internal.MqttBrokerHandlerFactory.<clinit>(MqttBrokerHandlerFactory.java:52) ~[?:?]

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_232]

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_232]

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_232]

at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_232]

at org.apache.felix.scr.impl.inject.ComponentConstructor.newInstance(ComponentConstructor.java:309) ~[?:?]

at org.apache.felix.scr.impl.manager.SingleComponentManager.createImplementationObject(SingleComponentManager.java:277) ~[?:?]

at org.apache.felix.scr.impl.manager.SingleComponentManager.createComponent(SingleComponentManager.java:114) ~[?:?]

at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:982) ~[?:?]

at org.apache.felix.scr.impl.manager.SingleComponentManager.getServiceInternal(SingleComponentManager.java:955) ~[?:?]

at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:900) ~[?:?]

at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse$1.run(ServiceFactoryUse.java:212) ~[org.eclipse.osgi-3.12.100.jar:?]

at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_232]

at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse.factoryGetService(ServiceFactoryUse.java:210) ~[org.eclipse.osgi-3.12.100.jar:?]

at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse.getService(ServiceFactoryUse.java:111) ~[org.eclipse.osgi-3.12.100.jar:?]

at org.eclipse.osgi.internal.serviceregistry.ServiceConsumer$2.getService(ServiceConsumer.java:45) ~[org.eclipse.osgi-3.12.100.jar:?]

at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:508) ~[org.eclipse.osgi-3.12.100.jar:?]

at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.getService(ServiceRegistry.java:461) ~[org.eclipse.osgi-3.12.100.jar:?]

at org.eclipse.osgi.internal.framework.BundleContextImpl.getService(BundleContextImpl.java:624) ~[org.eclipse.osgi-3.12.100.jar:?]

at org.apache.felix.scr.impl.manager.SingleRefPair.getServiceObject(SingleRefPair.java:86) ~[?:?]

at org.apache.felix.scr.impl.inject.BindParameters.getServiceObject(BindParameters.java:47) ~[?:?]

at org.apache.felix.scr.impl.inject.methods.BindMethod.getServiceObject(BindMethod.java:664) ~[?:?]

at org.apache.felix.scr.impl.manager.DependencyManager.getServiceObject(DependencyManager.java:2308) ~[?:?]

at org.apache.felix.scr.impl.manager.DependencyManager.doInvokeBindMethod(DependencyManager.java:1805) ~[?:?]

at org.apache.felix.scr.impl.manager.DependencyManager.invokeBindMethod(DependencyManager.java:1788) ~[?:?]

at org.apache.felix.scr.impl.manager.SingleComponentManager.invokeBindMethod(SingleComponentManager.java:435) ~[?:?]

at org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.addedService(DependencyManager.java:325) ~[?:?]

at org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.addedService(DependencyManager.java:294) ~[?:?]

at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1216) ~[?:?]

at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1137) ~[?:?]

at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.trackAdding(ServiceTracker.java:944) ~[?:?]

at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.track(ServiceTracker.java:880) ~[?:?]

at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:1168) ~[?:?]

at org.apache.felix.scr.impl.BundleComponentActivator$ListenerInfo.serviceChanged(BundleComponentActivator.java:125) ~[?:?]

at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:109) ~[org.eclipse.osgi-3.12.100.jar:?]

at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:920) ~[org.eclipse.osgi-3.12.100.jar:?]

at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) ~[org.eclipse.osgi-3.12.100.jar:?]

at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148) ~[org.eclipse.osgi-3.12.100.jar:?]

at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:862) ~[org.eclipse.osgi-3.12.100.jar:?]

at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:801) ~[org.eclipse.osgi-3.12.100.jar:?]

at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:127) ~[org.eclipse.osgi-3.12.100.jar:?]

at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:225) ~[org.eclipse.osgi-3.12.100.jar:?]

at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:469) ~[org.eclipse.osgi-3.12.100.jar:?]

at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:906) ~[?:?]

at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:892) ~[?:?]

at org.apache.felix.scr.impl.manager.RegistrationManager.changeRegistration(RegistrationManager.java:128) ~[?:?]

at org.apache.felix.scr.impl.manager.AbstractComponentManager.registerService(AbstractComponentManager.java:959) ~[?:?]

at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:732) ~[?:?]

at org.apache.felix.scr.impl.manager.AbstractComponentManager.enableInternal(AbstractComponentManager.java:666) ~[?:?]

at org.apache.felix.scr.impl.manager.AbstractComponentManager.enable(AbstractComponentManager.java:432) ~[?:?]

at org.apache.felix.scr.impl.manager.ConfigurableComponentHolder.enableComponents(ConfigurableComponentHolder.java:665) ~[?:?]

at org.apache.felix.scr.impl.BundleComponentActivator.initialEnable(BundleComponentActivator.java:338) ~[?:?]

at org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:382) ~[?:?]

at org.apache.felix.scr.impl.Activator.access$200(Activator.java:49) ~[?:?]

at org.apache.felix.scr.impl.Activator$ScrExtension.start(Activator.java:264) ~[?:?]

at org.apache.felix.scr.impl.AbstractExtender.createExtension(AbstractExtender.java:196) ~[?:?]

at org.apache.felix.scr.impl.AbstractExtender.modifiedBundle(AbstractExtender.java:169) ~[?:?]

at org.apache.felix.scr.impl.AbstractExtender.modifiedBundle(AbstractExtender.java:49) ~[?:?]

at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:482) ~[osgi.core-6.0.0.jar:?]

at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:415) ~[osgi.core-6.0.0.jar:?]

at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:232) ~[osgi.core-6.0.0.jar:?]

at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:444) ~[osgi.core-6.0.0.jar:?]

at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:908) ~[org.eclipse.osgi-3.12.100.jar:?]

at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) ~[org.eclipse.osgi-3.12.100.jar:?]

at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148) ~[org.eclipse.osgi-3.12.100.jar:?]

at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:213) ~[org.eclipse.osgi-3.12.100.jar:?]

at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:120) ~[org.eclipse.osgi-3.12.100.jar:?]

at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:112) ~[org.eclipse.osgi-3.12.100.jar:?]

at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:168) ~[org.eclipse.osgi-3.12.100.jar:?]

at org.eclipse.osgi.container.Module.publishEvent(Module.java:476) ~[org.eclipse.osgi-3.12.100.jar:?]

at org.eclipse.osgi.container.Module.start(Module.java:467) ~[org.eclipse.osgi-3.12.100.jar:?]

at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:383) ~[org.eclipse.osgi-3.12.100.jar:?]

at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:402) ~[org.eclipse.osgi-3.12.100.jar:?]

at org.apache.karaf.features.internal.service.BundleInstallSupportImpl.startBundle(BundleInstallSupportImpl.java:165) ~[?:?]

at org.apache.karaf.features.internal.service.FeaturesServiceImpl.startBundle(FeaturesServiceImpl.java:1153) ~[?:?]

at org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:1036) ~[?:?]

at org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1062) ~[?:?]

at org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$13(FeaturesServiceImpl.java:998) ~[?:?]

at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_232]

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_232]

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_232]

at java.lang.Thread.run(Thread.java:748) [?:1.8.0_232]

Caused by: java.lang.ClassNotFoundException: org.openhab.binding.mqtt.MqttBindingConstants cannot be found by org.openhab.binding.mqtt_2.5.8.202008170654

at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:433) ~[org.eclipse.osgi-3.12.100.jar:?]

at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:395) ~[org.eclipse.osgi-3.12.100.jar:?]

at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:387) ~[org.eclipse.osgi-3.12.100.jar:?]

at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:150) ~[org.eclipse.osgi-3.12.100.jar:?]

at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[?:1.8.0_232]

... 82 more

Uninstalled the legacy binding and after that everything started correctly :slight_smile:

You used to be able to have the MQTT 1.x binding and 2.x binding installed and in use at the same time. I’ve seen reports that it doesn’t work any more. But keep in mind, even when it was possible, the client ID that was used to connect to the broker has to be unique for each connection, meaning it has to be different in the mqtt.cfg and the MQTT Broker Thing.

I did it with my sonoff zigbee bridge with even less code (without the regex), with some extras taken from openHAB - Tasmota and with the last update time.

Things:

{   Thing topic Zbbridge1 "Zbbridge1 Sonoff" @ "Garage" {
      Channels:
        Type datetime : LastUpdate "LastUpdate" [stateTopic="tele/zbbridge1/STATE" , transformationPattern="JSONPATH:$.Time"]
        Type number : LoadAvg "LoadAvg" [stateTopic="tele/zbbridge1/STATE" , transformationPattern="JSONPATH:$.LoadAvg"]
        Type number : Vcc "Vcc" [stateTopic="tele/zbbridge1/STATE" , transformationPattern="JSONPATH:$.Vcc"]
        Type string : Version [stateTopic="stat/zbbridge1/INFO1", transformationPattern="JSONPATH:$.Version"]
      }

    Thing topic AqaraTemp02 "AqaraTemp02" @ "Cave" {
    Channels:
        Type string : Name "Name" [stateTopic="tele/zbbridge1/SENSOR" , transformationPattern="JSONPATH:$.ZbReceived.0x8171.Name"]
        Type datetime : LastUpdate "LastUpdate" [stateTopic="tele/zbbridge1/SENSOR" , transformationPattern="JSONPATH:$.ZbReceived.0x8171.Temperature"]
        Type number : Temperature "Temperature" [stateTopic="tele/zbbridge1/SENSOR" , transformationPattern="JSONPATH:$.ZbReceived.0x8171.Temperature", unit="°C"]
        Type number : Pressure "Pressure" [stateTopic="tele/zbbridge1/SENSOR" , transformationPattern="JSONPATH:$.ZbReceived.0x8171.Pressure" , unit="hPa"]
        Type number : Humidity "Humidity" [stateTopic="tele/zbbridge1/SENSOR" , transformationPattern="JSONPATH:$.ZbReceived.0x8171.Humidity" , unit="%"]
        Type number : BatteryVoltage "BatteryVoltage" [stateTopic="tele/zbbridge1/SENSOR" , transformationPattern="JSONPATH:$.ZbReceived.0x8171.BatteryVoltage" , unit="V"]
        Type number : BatteryPercentage "BatteryPercentage" [stateTopic="tele/zbbridge1/SENSOR" , transformationPattern="JSONPATH:$.ZbReceived.0x8171.BatteryPercentage" , unit="%"]
        Type number : LinkQuality "LinkQuality" [ stateTopic="tele/zbbridge1/SENSOR" , transformationPattern="JSONPATH:$.ZbReceived.0x8171.LinkQuality"]
      }

    Thing topic TuyaTemp01 "TuyaTemp01" @ "Cuisine" {
    Channels:
        Type string : Name "Name" [stateTopic="tele/zbbridge1/SENSOR" , transformationPattern="JSONPATH:$.ZbReceived.0xBF36.Name"]
        Type datetime : LastUpdate "LastUpdate" [stateTopic="tele/zbbridge1/SENSOR" , transformationPattern="JSONPATH:$.ZbReceived.0xBF36.Temperature"]
        Type number : Temperature "Temperature" [stateTopic="tele/zbbridge1/SENSOR" , transformationPattern="JSONPATH:$.ZbReceived.0xBF36.Temperature", unit="°C"]
        Type number : Pressure "Pressure" [stateTopic="tele/zbbridge1/SENSOR" , transformationPattern="JSONPATH:$.ZbReceived.0xBF36.Pressure" , unit="hPa"]
        Type number : Humidity "Humidity" [stateTopic="tele/zbbridge1/SENSOR" , transformationPattern="JSONPATH:$.ZbReceived.0xBF36.Humidity" , unit="%"]
        Type number : BatteryVoltage "BatteryVoltage" [stateTopic="tele/zbbridge1/SENSOR" , transformationPattern="JSONPATH:$.ZbReceived.0xBF36.BatteryVoltage" , unit="V"]
        Type number : BatteryPercentage "BatteryPercentage" [stateTopic="tele/zbbridge1/SENSOR" , transformationPattern="JSONPATH:$.ZbReceived.0xBF36.BatteryPercentage" , unit="%"]
        Type number : LinkQuality "LinkQuality" [ stateTopic="tele/zbbridge1/SENSOR" , transformationPattern="JSONPATH:$.ZbReceived.0xBF36.LinkQuality"]
      }

    Thing topic AqaraPlug01 "AqaraPlug01" @ "Garage" {
    Channels:
        Type string : Name "Name" [stateTopic="tele/zbbridge1/SENSOR" , transformationPattern="JSONPATH:$.ZbReceived.0xBB31.Name"]
        Type datetime : LastUpdate "LastUpdate" [stateTopic="tele/zbbridge1/SENSOR" , transformationPattern="JSONPATH:$.ZbReceived.0xBB31.Temperature"]
        Type switch : Power "Power" [stateTopic="tele/zbbridge1/SENSOR" , transformationPattern="JSONPATH:$.ZbReceived.0xBB31.Power", commandTopic = "cmnd/zbbridge1/zbSend", formatBeforePublish="{ device:0xBB31, send:{Power:%s} }" ]
        Type number : LinkQuality "LinkQuality" [ stateTopic="tele/zbbridge1/SENSOR" , transformationPattern="JSONPATH:$.ZbReceived.0xBB31.LinkQuality"]
      }

Items:

DateTime   Zbbridge1LastUpdate            "LastUpdate"          {channel="mqtt:topic:mosquitto-nas:Zbbridge1:LastUpdate" [profile="timestamp-update"]}
Number     Zbbridge1LoadAvg               "LoadAvg"             {channel="mqtt:topic:mosquitto-nas:Zbbridge1:LoadAvg"}
Number     Zbbridge1Vcc                   "Vcc"                 {channel="mqtt:topic:mosquitto-nas:Zbbridge1:Vcc"}
String     Zbbridge1Version               "Version"             {channel="mqtt:topic:mosquitto-nas:Zbbridge1:Version"}

String     AqaraTemp02Name                "Name [%s]"           {channel="mqtt:topic:mosquitto-nas:AqaraTemp02:Name"}
DateTime   AqaraTemp02LastUpdate          "LastUpdate"          {channel="mqtt:topic:mosquitto-nas:AqaraTemp02:LastUpdate" [profile="timestamp-update"]}
Number     AqaraTemp02Temperature         "Temperature"         {channel="mqtt:topic:mosquitto-nas:AqaraTemp02:Temperature"}
Number     AqaraTemp02Pressure            "Pressure [%s]"       {channel="mqtt:topic:mosquitto-nas:AqaraTemp02:Pressure"}
Number     AqaraTemp02Humidity            "Humidity"            {channel="mqtt:topic:mosquitto-nas:AqaraTemp02:Humidity"}
Number     AqaraTemp02BatteryVoltage      "Battery voltage"     {channel="mqtt:topic:mosquitto-nas:AqaraTemp02:BatteryVoltage"}
Number     AqaraTemp02BatteryPercentage   "Battery percentage"  {channel="mqtt:topic:mosquitto-nas:AqaraTemp02:BatteryPercentage"}
Number     AqaraTemp02LinkQuality         "Link quality"        {channel="mqtt:topic:mosquitto-nas:AqaraTemp02:LinkQuality"}

String     TuyaTemp01Name                "Name [%s]"            {channel="mqtt:topic:mosquitto-nas:TuyaTemp01:Name"}
DateTime   TuyaTemp01LastUpdate          "LastUpdate"           {channel="mqtt:topic:mosquitto-nas:TuyaTemp01:LastUpdate" [profile="timestamp-update"]}
Number     TuyaTemp01Temperature         "Temperature"          {channel="mqtt:topic:mosquitto-nas:TuyaTemp01:Temperature"}
Number     TuyaTemp01Pressure            "Pressure [%s]"        {channel="mqtt:topic:mosquitto-nas:TuyaTemp01:Pressure"}
Number     TuyaTemp01Humidity            "Humidity"             {channel="mqtt:topic:mosquitto-nas:TuyaTemp01:Humidity"}
Number     TuyaTemp01BatteryVoltage      "Battery voltage"      {channel="mqtt:topic:mosquitto-nas:TuyaTemp01:BatteryVoltage"}
Number     TuyaTemp01BatteryPercentage   "Battery percentage"   {channel="mqtt:topic:mosquitto-nas:TuyaTemp01:BatteryPercentage"}
Number     TuyaTemp01LinkQuality         "Link quality"         {channel="mqtt:topic:mosquitto-nas:TuyaTemp01:LinkQuality"}

String     AqaraPlug01Name                "Name [%s]"           {channel="mqtt:topic:mosquitto-nas:AqaraPlug01:Name"}
DateTime   AqaraPlug01LastUpdate          "LastUpdate"          {channel="mqtt:topic:mosquitto-nas:AqaraPlug01:LastUpdate" [profile="timestamp-update"]}
Switch     AqaraPlug01Power               "Power"               {channel="mqtt:topic:mosquitto-nas:AqaraPlug01:Power"}
Number     AqaraPlug01LinkQuality         "Link quality"        {channel="mqtt:topic:mosquitto-nas:AqaraPlug01:LinkQuality"}

Hope this can help.