MQTTv2 on 2.5.3

  • Platform information:

    • Hardware: CPUArchitecture/RAM/storage
      AMD64 Linux on Gigabyte BRIX AMD A6

    • OS: what OS is used and which version
      Ubuntu 19.10

    • Java Runtime Environment: which java platform is used and what version
      Part of Docker

    • openHAB version:
      2.5.3 Docker amd64-debian

  • Issue of the topic: please be detailed explaining your issue
    Trying to look at teh mqttv2 binding since that seems to be the way forward. mqtt broker is creating via thing.

Bridge mqtt:broker:mosquitto "Mosquitto MQTT Broker" @ "Network
" [ host="localhost", secure=false, port=1883, clientID="Melkor-Mqtt-thing"]

This never appears.

Have also tried creating another one in paper ui (with another name/client id) - this stays in Uninitialized state.

The error I see in the log after restarting the mqtt binding in karaf is:

2020-04-19 13:00:53.859 [ERROR] [org.openhab.binding.mqtt            ] - bundle org.openhab.binding.mqtt:2.5.3 (269)[org.openhab.binding.mqtt.internal.MqttBrokerHandlerFactory(281)] :  Error during in
stantiation of the implementation object
java.lang.NoClassDefFoundError: Could not initialize class org.openhab.binding.mqtt.internal.MqttBrokerHandlerFactory
        

2020-04-19 13:00:53.869 [ERROR] [org.openhab.binding.mqtt            ] - bundle org.openhab.binding.mqtt:2.5.3 (269)[org.openhab.binding.mqtt.internal.MqttBrokerHandlerFactory(281)] :  Error during in
stantiation of the implementation object
java.lang.NoClassDefFoundError: Could not initialize class org.openhab.binding.mqtt.internal.MqttBrokerHandlerFactory


2020-04-19 13:00:53.878 [ERROR] [org.openhab.binding.mqtt            ] - bundle org.openhab.binding.mqtt:2.5.3 (269)[org.openhab.binding.mqtt.internal.MqttBrokerHandlerFactory(281)] :  Error during in
stantiation of the implementation object
java.lang.NoClassDefFoundError: Could not initialize class org.openhab.binding.mqtt.internal.MqttBrokerHandlerFactory
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_232]
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]

There’s 3 errors there I think they’re all the same. I look at the bundle list as see a couple as Waiting.

288 │ Waiting │  80 │ 2.5.3                   │ openHAB Add-ons :: Bundles :: MQTT Broker Binding
289 │ Active  │  81 │ 2.5.3                   │ openHAB Add-ons :: Bundles :: MQTT Things and Channels
290 │ Active  │  82 │ 2.5.3                   │ openHAB Add-ons :: Bundles :: MQTT HomeAssistant Convention
291 │ Waiting │  82 │ 2.5.3                   │ openHAB Add-ons :: Bundles :: MQTT Homie Convention
292 │ Active  │  80 │ 2.5.0                   │ openHAB Core :: Bundles :: MQTT Transport

I did just see a post that said mqttv1 and 2 were incompatible? I didn’t think this was the case. I still heavily use MQTTv1 as I have not converted all my devices over yet.

The first question. What mqtt broker are you using and does it require a login?

Also, did you restart openHAB after preparing the thing file?

I use mosquito on docker. Always have. All the mqttv1 items are working fine.

Use openHAB has been restarted a number of time since the things file was created.

Any errors in the log when the .things file is loaded?

Are you using code fences above? The newline after "Network and the closing quote gives my pause.

I don’t use .things files for MQTT and don’t recommend them so won’t be of much help with the file. One thing that does catch a lot of people up is not having a unique Client ID for each broker Thing (and also the mqtt.cfg, they all have to be different from each other and different from any other client that logs into that broker).

The error posted above hints at a failed or corrupted binding install. I myself am running MQTT 2.5.3 so it should be possible to run it. You can try uninstalling it and reinstalling just the binding or go full on clear the cache and force the reinstallation of all your add-ons.

The fact that you have two MQTT bundles in the “Waiting” state is suspicious for sure. And the fact that one of them is the Broker Binding could explain the behavior.

Yeah that was a pasting error. That thing was working on my test system. But for some reason none of it is going with the newly updated prod system.

I did try removing the v2 binding and re-adding from paper ui on the first day after I’d upgraded. Haven’t tried since.

Hmm I removed the v1 binding and then I saw teh mqtt thing specified in the file appear…and no errors in the logs.

I thought you could have both running…

Though maybe order is important…So I uninstalled v2, then uninstalled v1, then installed v2 then v1.

Both now seem to be running…so that means i can now migrate things across.

1 Like

Thanks @psyciknz. Works for me. Guess it’s time to migrate the remaining v1 items to v2 now.
I’m quite happy to work with the .things config file. Unfortunatelly, the latest binding documentation doesn’t include examples any longer!

Here is an example thing thing in mqttv2. Note the broker I created via the UI and the broker thing is referenced - mqtt:broker:7d0ef5b3. The bindings page (https://www.openhab.org/addons/bindings/mqtt.generic/) has all of the pertinent information to set up the channel types and options. I’ve since switched to using “homie” discovery to avoid even having to keep track of these configurations but this works.

(for the thing name - mqtt:topic:hubitat:66 - i think it is important that be4 parts. first two set as mqtt:topic: - the third one I made match the name of my broker thing - the fourth a unique id for this device.)

Thing mqtt:topic:hubitat:66  "HE Patio"
     (mqtt:broker:7d0ef5b3)
{
     Channels:
     Type switch : switch "Switch"
     [
          on="on", off="off",
          stateTopic = "ha/hubitat/66/switch/state",
          commandTopic = "ha/hubitat/66/switch/cmd"
     ]

     Type colorHSB : color "Color "
     [
          stateTopic = "ha/hubitat/66/color/state",
          commandTopic = "ha/hubitat/66/color/cmd"
     ]

     Type dimmer : dimmer "Dimmer "
     [
          stateTopic = "ha/hubitat/66/level/state",
          commandTopic = "ha/hubitat/66/level/cmd"
     ]

     Type number : colorTemperature "Color Temperature"
     [
          stateTopic = "ha/hubitat/66/colorTemperature/state",
          commandTopic = "ha/hubitat/66/colorTemperature/cmd"
     ]
}