MQTT Binding: how to restrict incoming messages?

Hello everyone,

I managed to configure openHAB so that an Item can send its status in an MQTT message (via a JS script in a rule). This part is ok.

However, to do my tests, I configured the MQTT binding to the broker. I actually wanted to be able to deploy several “agents” which were not on the same network. The public broker did the trick.

The problem is that once the MQTT binding is activated… it receives ALL messages sent to test_mosquitto_org ! The inbox fills up VERY quickly :frowning:

Question: Is it possible to restrict the reception of messages to certain topics ? Or even configure MQTT binding only in publish mode ?

An alternative would be to use a local Mosquitto and, via a Python or JS script (already written), to bridge this local broker to test_mosquitto_org. But that would be an additional process to manage…


I guess you are using Linux?

If so run for Debian/Ubuntu:
apt install -y mosquitto

That will do the same thing as and if you put any “agents” (clients?) on another network you just use this mosquitto broker assuming your routing allows you to cross your network address, which is pretty much what you have done now but you will have control over what is sent to the broker, whereas you don’t have any control on the public broker.

Thank you for your answer Greg.

Yes, that’s what I’ve already tested before. But my broker will not be reachable from outside my university’s network. That’s why I was thinking of just using Mosquitto’s public broker. In any case during the testing phase :wink:

But I think that I will indeed not be able to do without a private broker, as indicated in your answer.


You could set up the broker on the same network as openhab and then set up myopenhab which is hosted externally.
I have never used myopenhab but it looks like it may work for you?

Found a “clean” workaround: I set up a local Mosquitto and I configured it in bridge mode to public Mosquitto broker (input and output) only for my topics. In mosquitto.conf I added this:

bridge to

connection bridge-01
topic /path/to/my/topic/# both 0

And it works in both directions without “flooding” :wink:


If I understand correctly, once the Broker Thing comes online it discovers a bunch of Homie or Home Assistant or any of the other MQTT standard topic layouts automatically and loads up your Inbox with potential Things.

If that’s true and if you don’t need auto discovery, on the Broker Thing click “show advanced” and at the bottom there is a toggle to turn off Discovery. That will stop the binding from looking for new devices and only Generic MQTT Things are possible, which is what you want anyway I think. Then you don’t need the bridge.

Ideally, a self hosted broker is going to be more secure and risky.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.