MQQT brocker in the same container with HA

I am in the process of migrating from Domoticz to HA.
Domoticz is installed on the RPi along with the MQTT server. Most devices work with Domoticz via MQTT.
I installed HA in docker on QNAP NAS. It works and automatically detected the MQTT broker on the RPi.
I installed the MQTT broker via CLI in the same docker where HA is located.
The logs and verbose mode show that the MQTT client from RPi logs into the broker on the NAS HA container.

QNAP NAS container broker logs:

home-assistant:/# mosquitto -v -c /etc/mosquitto/mosquitto.conf 
1695292082: mosquitto version 2.0.15 starting
1695292082: Config loaded from /etc/mosquitto/mosquitto.conf.
1695292082: Opening ipv4 listen socket on port 1883.
1695292082: mosquitto version 2.0.15 running
1695292083: New connection from 127.0.0.1:50478 on port 1883.
1695292083: New client connected from 127.0.0.1:50478 as auto-67B9EC2F-572E-4C26-FBC8-77C0F9FA4BED (p2, c1, k60).
1695292083: No will message specified.
1695292083: Sending CONNACK to auto-67B9EC2F-572E-4C26-FBC8-77C0F9FA4BED (0, 0)
1695292083: Received SUBSCRIBE from auto-67B9EC2F-572E-4C26-FBC8-77C0F9FA4BED
1695292083:     test/test (QoS 0)
1695292083: auto-67B9EC2F-572E-4C26-FBC8-77C0F9FA4BED 0 test/test
1695292083: Sending SUBACK to auto-67B9EC2F-572E-4C26-FBC8-77C0F9FA4BED
1695292095: New connection from 192.168.0.25:57162 on port 1883.
1695292095: New client connected from 192.168.0.25:57162 as mosqpub/503-NanoPi-NEO (p1, c1, k60).
1695292095: No will message specified.
1695292095: Sending CONNACK to mosqpub/503-NanoPi-NEO (0, 0)
1695292095: Received PUBLISH from mosqpub/503-NanoPi-NEO (d0, q0, r0, m0, 'test/test', ... (9 bytes))
1695292095: Sending PUBLISH to auto-67B9EC2F-572E-4C26-FBC8-77C0F9FA4BED (d0, q0, r0, m0, 'test/test', ... (9 bytes))
1695292095: Received DISCONNECT from mosqpub/503-NanoPi-NEO
1695292095: Client mosqpub/503-NanoPi-NEO disconnected.

Publish from RPi to QNAP NAS

root@NanoPi-NEO:/home/pi/domoticz# mosquitto_pub -h ha -t "test/test" -m "testujemy"

Logs from the broker on the NAS

home-assistant:/mosquitto# mosquitto_sub -v -t "test/test"
test/test testujemy

I don’t know how to make HA see MQTT in its own container and download information from it for communication with devices. Any help? “Uncle Google” didn’t tell me anything interesting.

Settings → Devices & Services → +add integration → mqtt

I’m a little confused.

You have Mosquito running on Docker on your Pi
You have HA running in docker on your QNAP NAS

…are you trying to move Mosquitto to docker on your NAS as well?

I believe ether MQTT integration can only link to a single Mosquitto instance at a time. If you want it to see your NAS instance you need to reconfigure MQTT within HA Integrations to look at the NAS instance (you may be able to use localhost as the URL, but not sure about this).

I don’t want to use 2 brokers at the same time. I want HA to work with its own. The one on RPi must remain for the duration of migration because the automation must work.

The MQTT integration can only talk to one broker. So you will have to reconfigure the MQTT integration to talk to its own broker.


The result is “Brocker already configured…” (or so).
It probably means a working tracker on RPi. And I want HA to cooperate with its own broker.

So, reconfigure. See my post above

OK, I know. So what to do to work it only with own brocker? Any yaml file to edit? No problem byt which one and what to enter?

No .yaml to edit, it is config flow

Settings → Devices & Services → MQTT
image

As I wrote - The result is “Brocker already configured…” (or so).
It probably means a working tracker on RPi. And I want HA to cooperate with its own broker.
Such option as above is not avaliable.

It is always there, but if you don’t want the easy way

Settings → Devices & Services → MQTT

restart HA

Settings → Devices & Services → +add integration → mqtt

1 Like

OK. THX! Works!.
Don’t be offended if I ask a few more questions in the future, because I’m starting with HA and I’ve had Domoticz for about 10 years. Well, it’s time to migrate.
Thanks again.

You really should have the broker installed in its own container though.