MQTT System broker Vs. MQTT Embedded broker

Hello all
i’m begginner and struggling at initial configuration/setup problem.
In Paper UI i’ve found already present a System Broker:

MQTT Broker
System MQTT Broker
mqtt:systemBroker:embedded-mqtt-broker

After read documentation i’ve also found that OH2 has an embedded broker, so installed it.
Now i would like to remove the System Broker but after clicked on the button to remove it, i’m getting it always in ‘REMOVING’ status and also it show up in the logs…

2019-02-15 07:51:49.944 [INFO ] [.reconnect.PeriodicReconnectStrategy] - Try to restore connection to ‘98.87.89.1’. Next attempt in 10000ms

2019-02-15 07:51:49.956 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to ‘98.87.89.1’ with clientid paho1698040587602 and file store ‘/var/lib/openhab2/mqtt/98.87.89.1’

2019-02-15 07:51:59.959 [INFO ] [.reconnect.PeriodicReconnectStrategy] - Try to restore connection to ‘98.87.89.1’. Next attempt in 10000ms

2019-02-15 07:52:09.962 [INFO ] [.reconnect.PeriodicReconnectStrategy] - Try to restore connection to ‘98.87.89.1’. Next attempt in 10000ms

2019-02-15 07:52:19.965 [INFO ] [.reconnect.PeriodicReconnectStrategy] - Try to restore connection to ‘98.87.89.1’. Next attempt in 10000ms

2019-02-15 07:52:29.968 [INFO ] [.reconnect.PeriodicReconnectStrategy] - Try to restore connection to ‘98.87.89.1’. Next attempt in 10000ms

2019-02-15 07:52:39.971 [INFO ] [.reconnect.PeriodicReconnectStrategy] - Try to restore connection to ‘98.87.89.1’. Next attempt in 10000ms

2019-02-15 07:52:49.975 [INFO ] [.reconnect.PeriodicReconnectStrategy] - Try to restore connection to ‘98.87.89.1’. Next attempt in 10000ms

2019-02-15 07:52:59.979 [INFO ] [.reconnect.PeriodicReconnectStrategy] - Try to restore connection to ‘98.87.89.1’. Next attempt in 10000ms

2019-02-15 07:52:59.990 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to ‘98.87.89.1’ with clientid paho1698040587602 and file store ‘/var/lib/openhab2/mqtt/98.87.89.1’

Any idea?

Whats the differences between the two brokers?

TIA

H

Yes that is complicated if you see the Paper UI interface the first time. That’s why Paper UI will be replaced this year with something better.

You browsed the “Service” part of Paper UI and there you have found “MQTT System Broker”, right?
Unfortunately that service part is for distributors only, that want to pre-configure openHAB for others.
If you have added a “system broker” there, it is impossible to remove it via Paper UI again (a bug within Paper UI, that will not be fixed anymore :/). You must delete the created file on the file system.

As soon as you have clicked anything over there, there will appear that “System Broker Thing” in your Inbox. But as I said, that is not usable or configurable by you.

What you actually want, is the Inbox+Thing section only. You first install the embedded broker (or mosquitto as an external broker) and then you go into Things->Manually add Thing->Broker Thing.

This confusion will hopefully be solved with a replaced Paper UI in the future.

Cheers, David

2 Likes

Thank you David - got it.
As you said, i must delete the created file on fs. BUT… where is this file?
If i’m not wrong i believe this information (MQTT System broker) was stored in an internal OH2 db… anyway this is only my thought :wink:

I just would like to get rid of those wanings in the logs and from seeing it on service section.

TIA

H

It is a bit more complicated. There is an internal “database”, yes. That is json formatted.

But services store their configuration not within that database, but in separate files. The name depends on the service name (in this case something like “mqtt.config” or “mqtt.cfg”). I don’t know the exact name, you would need to look in your openHAB runtime directory. Delete the file while OH is NOT running and the errors are gone.

Hello David
those files are present but actually empty. Anyway i’ll give it a try and report back.

Thank you!

H

…done.
After deleting mqtt.cfg, i finally get System Broker in a uninitialized/disabled state and that stopped flooding logs file.

Thank you

H

Hi David

So what you are saying is, instead of installing the regular MQTT Binding we need to install the MQTT Embedded Binding then we will be able to create MQTT connections?

John Frankforther

Nope, I never said that. The embedded broker is really just that, an MQTT broker embedded into openHAB. Completely independent. You can use the embedded broker without using the mqttv2 binding for example. And you can use the mqtt1 or mqtt2 binding without the embedded broker.

Ok, I did install the embedded broker but it didn’t show up under things to use. I read in your MQTT docs that you just install the embedded binding and it is supposed to show up in the inbox. I was looking over your instructions

All you have to do is, installing the addon in Paper UI to have a working MQTT broker, ready to use.

You can optionally configure the embedded broker in the service section of PaperUI (or via text files as usual):

Is there something I’m missing? Thanks for any information. I had it working once.

John

If you install the mqtt broker only it cannot be used by openHAB itself. It is an mqtt broker.

You need the mqtt binding to be installed as well. It will auto discover the embedded broker and make it available as “Thing”. Or you can manually add a broker thing that is configured to use another broker like mosquito.

Thank you David ! I didn’t install the MQTT binding along with the embedded one this time.
I’m slowly getting it!!

(update) Thank you again David!! New install of everything and it is working again with no errors in the log file. This is a much easier way to setup MQTT and the ESP8266’s using Tasmota.

Many thanks.

John Frankforther

john
can you please summarize all the step that you did to get it working. i am facing similar issues where my mqtt communication stopped working.

thanks much
sudhansu

Basically what I did was to remove the embedded MQTT and the MQTT bindings themselves and install them again via the Paper UI screen. Then I went back and made all the connections again.
First, make the connection to the main MQTT broker. David Graeff put together good information on MQTT 2.4 here

Since I’m using the Tasmota software, I have to use the generic MQTT binding to connect my ESP8266 boards to OH2. I only have 3 boards connected to my system and I have done this a many times before so I could almost do it in my sleep. So far, knock on wood, the system has been running almost 24 hours with no errors, all the sensors are reporting live data and the On/Off switch is working.

John Frankforther

My apologies for the noob question but where is the openhab runtime directory on a pi3 installed with openhabian? I am also getting lots off errors with mqtt and the mqtt broker eventually stopping.

Where did you find this file?
I have the problematic “distributor” mqtt in services on Paper UI as well and want to get rid of it.
My cfg files are in /etc/openhab2/services, but there is no mqtt.cfg or similar.
When OH is running these .cfg files are usually copied to /srv/openhab2-userdata/config/org/openhab/ with extension .config (AFAIK).
None of these exist.

I just found these:

mqttembeddedbroker.config
mqttbroker.config

According to David above (sorry if I got you wrong, @David, because there are too many mqtts involved :wink:
the first one should be the config which is about the internal (embedded) mqtt broker of OH (I intend using mosquitto instead), the second is the “distributors only” which can be found in PaperUI -> configuration -> services (I guess!?)

EDIT:
After deleting the two files above (after shutting down OH), no negative effect is obvious.
AND: I don’t get the mqtt stuff being discovered anymore (was very annoying).

one question though :wink:
My mqtt item looks like this:

Switch Xido_Mot "Xido Motion" (G_jdbc){channel="mqtt:broker:mosquitto:Xido_onMotion"}

I can see the channel being triggered:

2020-05-26 12:51:29.508 [vent.ChannelTriggeredEvent] - mqtt:broker:mosquitto:Xido_onMotion triggered {"type":"visual","deviceId":"xxx-xxx","event":"onMotion"}

Currently I use this to trigger a rule:

rule "Motion Trigger handling"
when
    Channel "mqtt:broker:mosquitto:Xido_onMotion" triggered
then

Is it possible to define the item (Switch) above to switch ON if the event onMotion is triggered?

You won’t find it unless you installed MQTT binding version 1.x

That would be something to look at in your still secret channel configuration.

I think however you cannot set the same channel to be both trigger type and update Item states.
You could make another channel.

:smiley:
Fair enough:
to mosquitto FKB publishes:
fully/event/onMotion/xxx-xxx

so my PublishTrigger is setup for
fully/event/onMotion/xxx-xxx

It does not need to be the same channel.
I just would like the item (Switch) using the mqtt-channel to change to ON to trigger something else.

Yes. Your topic Thing channel configuration is still secret, but essentially you can copy the trigger version but without the trigger option. You’ll probably want some transformation to extract the bit of JSON you are interested in, and massage into an ON/OFF state for your switch.

If you have created an Item receiving updates … you can trigger a rule from that, and maybe would have no need of your trigger channel now?

None of this has anything to do with embedded brokers etc.

Sorry, I am not quite sure, whats missing.

I use mosquitto and have discovered the broker thing

MQTT Broker (mosquitto) ONLINE

MQTT Broker
mqtt:broker:mosquitto

In this thing I created a publishTrigger channel with the mqtt topic
fully/event/onMotion/xxx-xxx
named
mqtt:broker:mosquitto:Xido_onMotion

This all triggers the rule above - which is “good enough”.
So, the channel definition on Xido_Mot is not needed at all.

I just would like to know a cleaner / leaner way of the mqtt channel like on http:
{http=">[ON:GET:http://192.168.68.40:2323...

I don’t have a clue what you mean, but I assume it’s about my statement above (Xido_Mot channel)

You are right - sorry for that.
I just “stayed” here because @David_Graeff clarification about the various mqtt components (which was always confusing for me).

However, I might place a separate topic with my question above.

Thanks for your help!