Please help!A little confusion about MQTT Event Bus Binding

Hello friends,
I’ve been playing OH2 (with raspberry pi 3) for a month and I am really enjoy its performance. As I want to expand my system so I’m gonna add a 2nd raspberry pi to do several other tasks (because I realize it’s too much for just one raspberry pi 3 to satisfy all of my needs)
I’ve been searching in this forum and found MQTT Event Bus binding is the exact thing that can make my plan possible. But I am pretty confused about some parts and I couldn’t make event bus work eventually.So I hope some experts can help me answer below question and guide me to do it from the scratch:

I have a raspberry pi 3 (the original one), which has the broker’s name is “mymosquitto” inside mqtt.cfg file. Recently, I has just bought a brand new raspberry pi and I named its broker’s name is" slave".
I did copy all of the items, sitemaps, rules, transform, scripts, icons,… files (I mean every files) from the original raspberry pi to the new one.

How exactly can I do that for both sides?
Can anybody help? I would be very grateful

It’s difficult to know from the description, but when you say you are using two broker names do you mean you have two brokers? If so, both the master and slave must connect to the same broker.

You need to configure the slave to publish item state updates to a topic and to listen for commands on a different topic (e.g., publish to openhab/state/${item} and subscribe to openhab/command/${item}).

The master must be configured to publish commands to the command topic and to subscribe to item state updates from the slave (e.g., publish to openhab/command/${item} and subscribe to openhab/state/${item}).

If this isn’t working for you, maybe you could show us the mqtt-eventbus.cfg you are using for the master and the slave.

Ahhh thanks for your quick reply.
Since I read your comment:

but when you say you are using two broker names do you mean you have two brokers? If so, both the master and slave must connect to the same broker.

Now I know that there is a silly mistake. At first I thought master and slave are required to have 2 separated brokers.

Now I understand that I only need 1 broker name for both of them. So I suppose the configuration should be:
On the master side:

Meanwhile, on the slave side:

Am I right? Please correct me If am wrong. And please check the above configuration!! Thanks!

It’s closer, but both sides must also publish and subscribe to the same topic (one topic for state and another for commands). For example, /openHAB/out/${item}/command and /openHAB/in/${item}/command are different topics (different names) so the subscriber will not receive messages that are published on the separate topic. You should use something like /openHAB/${item}/command for both sides.

OK then you mean is:


Sorry If I demand to much, I’m quite slow at understanding things, I hope you can reply

It looks to me like it should work. The best thing to do is try it and see what happens.

Did you get this working? This is exactly what I am trying to achieve and believe I have configured, although no state changes are passed from slave to master.
Go I need to configure item files for each device to push to mqtt? I think not as the point of the event-bus.cfg is to push everything?
Mqtt and mosquito is working fine with test messages. OH2 does not seem to push anytging via event-bus, I see nothing referring to mqtt in the logs with debug enabled on the mqtt binding.

I have 2 Pi’s working as master and slave using mqtt-eventbus

Master mqtt-eventbus.cfg reads


Slave mqtt-eventbus.cfg reads


On both Pi’s the broker is names as “mosquitto” in mqtt.cfg

I am using the same broker for both

On the master Pi anything destined for the slave (Pi2) needs sending as sendCommand, and on the slave Pi anything destined for the master needs sending as postUpdate.

Overall it works well, and I’d recommend finding a program like mqtt.fx to monitor mqtt messages to see if it is behaving as you expect

Thanks for the reply and pretty much what I have. How do you configure your items? Only on the master or on both? Do you have to define mqtt in the item file or not as everything is published to the Event Bus?

No mqtt information needed for each item, as the eventbus takes care of it. I only add mqtt information to items if the information is coming in from, or going out to something other than OpenHAB…
You still need to add items to each machine, although you only need to add the ones on each machine that you need on it. For items to be available on both machines they need adding to both machines.
In my configuration I have a backend Pi that does most of the repetitive stuff, with a few bindings to allow it to talk to other things. Then my main Pi is reserved for the user interface and other bindings where latency may be noticeable. My backend Pi also runs EMONCMS for energy monitoring.
Be aware that you may miss the odd update if the broker is very busy

Thanks for the help. I duplicated your syntax and have it working now. Only changes were to mqtt-eventbus.cfg transposing command / state and ${item} positions in the config.

1 Like

Hi Kevin

Can I just ask, do you have to change something in your .items file, when using this Event bus?

Sorry for the noob question :slight_smile:

You need to add nothing at all to the items, however you need to pay attention to anything that is incoming or outgoing. Lets assume you have mqtt-eventbus.cfg in your /etc/openhab2/services with the following information in the file on the master Pi


and for completeness the following information in the slaves file


If you then add an item to the master that is linked to MQTT with the following details

Number Test {mqtt="<[mosquitto:TestTopic/TestItem:command:default]"}

You should find that both machines are updated whenever a Number is published to TestTopic/TestItem

However if you change the word “command” to “state” you will find that only the changes appear on the master unit ONLY. See below

Number Test {mqtt="<[mosquitto:TestTopic/TestItem:state:default]"}

The reverse happens for the slave, which needs slave in the items instead of command.
Similarly in your rules for anything to pass between the units you need to use sendCommand on the master, and postUpdate on the slave.
What I’d suggest going forward is you download mqtt.fx from and use that to subscribe to the topics so you can see what is being passed across the broker. Subscribing to "# " will show you all information, although once your system grows you’ll likely find this to be too busy, and you#ll want to look at either the individual topics, or just the eventbus traffic as “Slave/#”

Hi evin

Thanks for the reply.

So i kept my items “as is” and copied them to machine 2, and started my broker/event bus (with the parameters you described, with my own broker name).
And then i was all set!

I can see that all my items are being picked up by the Event bus, in my “sniffer” (MQTTfx), I can see all the items being updated on the MQTT event bus, but my items on the 2nd machine, are not updated. :frowning:
If I use MQTT and publish a topic from machine 1, I make a subscription on machine 2, and BAM! items is updated.

I reinstalled the MQTT items, and the MQTT action, but still nothing.


Edit: BTW if I make the item as you described

Number Test {mqtt="<[mosquitto:TestTopic/TestItem:state:default]"}

but just “>” instead of “<” (outbound instead f indbound), i get an error telling me that the MQTT item MUST contain of 5 parts, divided by :

AAhhh @kevin I see now for the first time what is “wrong”, and only see it by installing MQTfx.
All my items ARE infact updated BUT NOT in my Sitemaps which is crazy stupid, i think.

As I see it, my only way to make my sitemap updated on both machines, is to make rules, and then a postupdate of all the items I want to have in my sitemap.

Is this wrong?

On the second machine all you need it the item itself

Number Test

As the information from machine one is coming in via the event bus. What you should have is machine 1 updating the interface of machine 2.

Just to confirm does machine 2 not update machine 1’s sitemap? Can you see messages from machine 2 with mqtt.fx?