[SOLVED] Trying to Start Migration to MQTT2

I am running openHABian 2.4.0-1

I use mosquitto as my MQTT broker. I had SSL set up to use the OwnTracks binding to receive location data via MQTT. I have transitioned to the GPSTracker binding using HTTP and myopenhab.org. This allowed me to get rid of the SSL portion of the broker setup. This means that I now have a simple broker with one listener on 1883.

I have a working mqtt1 setup with several smart switches. All of my Items are declared using .items files using the mqtt1 syntax.

I installed openHABian 2.4.0-1 on another Raspberry Pi and figured out to to get mqtt2 configured using mosquitto and a few MQTT smart switches. Simple setup but got it working.

Now I want to begin the migration of my home server. I installed the mqtt2 binding and added the Generic MQTT Broker Thing. I cannot get it to connect to mosquitto.

openhab> bundle:list -l | grep mqtt
211 ¦ Active   ¦  80 ¦ 1.2.0        ¦ mvn:org.eclipse.paho/org.eclipse.paho.client.mqttv3/1.2.0									¦ Paho MQTT Client
214 ¦ Active   ¦  80 ¦ 0.10.0.oh240 ¦ mvn:org.eclipse.smarthome.binding/org.eclipse.smarthome.binding.mqtt/0.10.0.oh240			¦ Eclipse SmartHome MQTT Binding
215 ¦ Active   ¦  80 ¦ 0.10.0.oh240 ¦ mvn:org.eclipse.smarthome.binding/org.eclipse.smarthome.binding.mqtt.generic/0.10.0.oh240	¦ Eclipse SmartHome MQTT Thing Binding
217 ¦ Active   ¦  80 ¦ 0.10.0.oh240 ¦ mvn:org.eclipse.smarthome.io/org.eclipse.smarthome.io.transport.mqtt/0.10.0.oh240			¦ Eclipse SmartHome MQTT Transport Bundle
233 ¦ Active   ¦  80 ¦ 1.13.0       ¦ mvn:org.openhab.binding/org.openhab.binding.mqtt/1.13.0									¦ openHAB MQTT Binding
241 ¦ Active   ¦  80 ¦ 1.13.0       ¦ mvn:org.openhab.io/org.openhab.io.transport.mqtt/1.13.0									¦ openHAB MQTT Transport Bundle

There is nothing in mosquitto.log at the time of the openHAB restart. I set the openHAB logging level for the mqtt2 bundles to TRACE and captured this in the log:

22.504 [DEBUG] [lipse.smarthome.binding.mqtt.generic] - ServiceEvent REGISTERED - {org.eclipse.smarthome.core.thing.type.ChannelTypeProvider, org.eclipse.smarthome.core.thing.type.ChannelGroupTypeProvider, org.eclipse.smarthome.binding.mqtt.generic.internal.generic.MqttChannelTypeProvider}={service.id=128, service.bundleid=215, service.scope=bundle, component.name=org.eclipse.smarthome.binding.mqtt.generic.internal.generic.MqttChannelTypeProvider, component.id=21} - org.eclipse.smarthome.binding.mqtt.generic
22.532 [DEBUG] [lipse.smarthome.binding.mqtt.generic] - ServiceEvent REGISTERED - {org.eclipse.smarthome.core.thing.type.DynamicStateDescriptionProvider, org.eclipse.smarthome.binding.mqtt.generic.internal.generic.MqttChannelStateDescriptionProvider}={service.id=129, service.bundleid=215, service.scope=bundle, component.name=org.eclipse.smarthome.binding.mqtt.generic.internal.generic.MqttChannelStateDescriptionProvider, component.id=23} - org.eclipse.smarthome.binding.mqtt.generic
22.540 [DEBUG] [lipse.smarthome.binding.mqtt.generic] - ServiceEvent REGISTERED - {org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory}={service.id=130, service.bundleid=215, service.scope=bundle, component.name=org.eclipse.smarthome.binding.mqtt.generic.internal.MqttThingHandlerFactory, component.id=24} - org.eclipse.smarthome.binding.mqtt.generic
22.553 [DEBUG] [lipse.smarthome.binding.mqtt.generic] - BundleEvent [unknown:512] - org.eclipse.smarthome.binding.mqtt.generic
23.550 [DEBUG] [lipse.smarthome.binding.mqtt.generic] - BundleEvent STARTING - org.eclipse.smarthome.binding.mqtt.generic
23.555 [DEBUG] [lipse.smarthome.binding.mqtt.generic] - BundleEvent STARTED - org.eclipse.smarthome.binding.mqtt.generic
54.413 [DEBUG] [org.eclipse.smarthome.binding.mqtt  ] - BundleEvent STARTING - org.eclipse.smarthome.binding.mqtt
54.456 [DEBUG] [org.eclipse.smarthome.binding.mqtt  ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.config.discovery.DiscoveryService}={service.id=373, service.bundleid=214, service.scope=bundle, component.name=org.eclipse.smarthome.binding.mqtt.internal.discovery.MqttServiceDiscoveryService, component.id=217} - org.eclipse.smarthome.binding.mqtt
54.524 [DEBUG] [lipse.smarthome.binding.mqtt.generic] - ServiceEvent REGISTERED - {org.eclipse.smarthome.config.discovery.DiscoveryService}={service.id=375, service.bundleid=215, service.scope=bundle, component.name=org.eclipse.smarthome.binding.mqtt.generic.internal.discovery.HomeAssistantDiscovery, component.id=20} - org.eclipse.smarthome.binding.mqtt.generic
54.536 [DEBUG] [lipse.smarthome.binding.mqtt.generic] - ServiceEvent REGISTERED - {org.eclipse.smarthome.config.discovery.DiscoveryService}={service.id=376, service.bundleid=215, service.scope=bundle, component.name=org.eclipse.smarthome.binding.mqtt.generic.internal.discovery.Homie300Discovery, component.id=22} - org.eclipse.smarthome.binding.mqtt.generic
54.542 [DEBUG] [org.eclipse.smarthome.binding.mqtt  ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory, org.eclipse.smarthome.binding.mqtt.discovery.MQTTTopicDiscoveryService}={service.id=374, service.bundleid=214, service.scope=bundle, component.name=org.eclipse.smarthome.binding.mqtt.internal.MqttBrokerHandlerFactory, component.id=218} - org.eclipse.smarthome.binding.mqtt
54.565 [DEBUG] [org.eclipse.smarthome.binding.mqtt  ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.core.thing.binding.ThingActions}={service.id=377, service.bundleid=214, service.scope=bundle, component.name=org.eclipse.smarthome.binding.mqtt.action.MQTTActions, component.id=219} - org.eclipse.smarthome.binding.mqtt
54.568 [DEBUG] [org.eclipse.smarthome.binding.mqtt  ] - BundleEvent STARTED - org.eclipse.smarthome.binding.mqtt
54.642 [DEBUG] [org.eclipse.smarthome.binding.mqtt  ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.core.thing.binding.ThingActions}={service.id=379, service.bundleid=214, service.scope=singleton} - org.eclipse.smarthome.binding.mqtt
54.875 [WARN ] [ternal.TopicSubscribeMultiConnection] - Failed to MQTT subscribe for mqtt:broker:mosquitto on topic homie/+/$homie
54.880 [TRACE] [ternal.TopicSubscribeMultiConnection] - Found suitable bridge mqtt:broker:mosquitto for listing to topic homie/+/$homie
54.882 [WARN ] [ternal.TopicSubscribeMultiConnection] - Failed to MQTT subscribe for mqtt:broker:mosquitto on topic homeassistant/#
54.884 [TRACE] [ternal.TopicSubscribeMultiConnection] - Found suitable bridge mqtt:broker:mosquitto for listing to topic homeassistant/#

I have restarted openHAB. I have cleared out the cache & tmp directories and restarted openHAB. I have checked and triple checked that I have the mosquitto host, user, and password entered correctly (I checked the Thing via REST to ensure that the password was correct). The broker Thing will not connect to mosquitto. I cannot figure out what I am doing wrong. Any guidance is appreciated.



The MQTT Version of the 2.4 stable release does have known problems (because of that the author always suggests to go for the 2.5 Version).
I THINK a simple restart (bundle or openHAB) could solve your actual problem . However if you want to use autodiscovery (assuming that from the “homie” and “homeassistant” entries in the log) the switch to 2.5 migth be needed anyhow.

1 Like

As I’m interested in this problem too, as I want to migrate, step by step, to the new MQTT2-Version.

I’m on OH, running MQTT1 with Mosquitto installed and credencials in mqtt.cfg in a minimal config

# URL to the MQTT broker, e.g. tcp://localhost:1883 or ssl://localhost:8883

I want to ask, if it is necessary to install the broker in the PaperUI after installing the MQTT2-Binding with PaperUI?

I created a Bridge/Thing for this:

Bridge mqtt:broker:peter "Mosquitto" [ host="localhost", port=1883, secure=false, clientID="OH2"
    // Sonoffs
    Thing topic sonoffs20 "Sonoff S20" @ "Some Room" {
        Type string : reachable "Reachable"            [ stateTopic="tele/sonoff-s20/LWT" ]
        Type switch : power     "Power"                [ stateTopic="stat/sonoff-s20/POWER", commandTopic="cmnd/sonoff-s20/POWER" ]
        Type number : rssi      "WiFi Signal Strength" [ stateTopic="tele/sonoff-s20/STATE", transformationPattern="JSONPATH:$.Wifi.RSSI"]

So in my simply understanding this is the link (Bridge) to the Broker and even for a first Thing, isn’t it ?

Sorry for my stupid question

Correct! But that is only a Broker Thing (a bridge). Installing and starting a (embedded) MQTT broker via PaperUI is also possible, with a running Mosquitto broker that is not needed. I would not use the verb “installing” for the creation of that Broker Thing.

1 Like

Upgraded to latest 2.5 Snapshot. Problem remains.

In this case something else has to be be wrong.
When compairing the picture of your initial post to my setup (done via file, still on 2.4) I see an incomplete IP ( I guess that was on purpose) and that is all what differs (except user and password).
Frankly, I have no clue!

How did you setup the generic mqtt things for the switches?

Your config looks very much like mine. I’d recommend not turning on Retained messages in the Broker Thing.

Try defining the client ID and make sure it is unique.

Try to connect to the broker using the same information using an MQTT client to see if the problem is in OH or in the connection info.

Beyond that I’m at a lost.

1 Like

@opus - Yes, I’ve masked some of my details.

On this system I have not added any Generic Things because the broker connection is not working.

I tried stopping the mqtt1 binding bundles and restarting the mqtt2 bundles. No change.

TRACE level log output provides no additional insights.

@rlkoshak - I deleted the broker Thing and recreated it letting openHAB pick the UID to ensure that it is unique. No change.

My mqtt1 instance is operational (MQTT traffic). I also verified that I can establish additional connections to the broker by using MQTT Explorer.

@David_Graeff - do you have any guidance on where to look for additional information?



Not the UID of the Thing. I’m talking about the Client ID. Second row left column after “SHOW LESS” in your screenshot.

I saw ID. I saw unique. I skipped right over the Client :wink:

Still no joy.


P.S. and now, due to the 2.5 upgrade, not REST docs :frowning_face:

Explicitly provide the port as well. A timeout error can really only happen if no connection could be established. Check firewalls and if the host is reachable.

It depends on what version of 2.5 you are telling about but apparently in the snapshots since Monday. There seems to be a problem with the Chromecast binding breaking the rest docs.

openHAB 2.5.0~S1672-1 (Build #1672) Installed around noon (EDT) today.

openHAB is running on the same Raspberry Pi as mosquitto. mqtt1 connects to the broker without issue.

I don’t think there is a firewall active on my server

iptables -L -nv
Chain INPUT (policy ACCEPT 2476 packets, 694K bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain OUTPUT (policy ACCEPT 1505 packets, 437K bytes)
 pkts bytes target     prot opt in     out     source               destination

I downgraded from 2.5.0~S1672-1 to 2.5.0~M2-1 and the Generic Broken connects and is online. I backed out the ClientID and the Port (both blank) and it still connects.


P.S. My REST Docs are still broken :frowning_face: