External secondary MQTT broker

Raspi 3, Version HA 2021.12.10

I am having problems to configure an external MQTT broker on an external server running mosquito (no HA there).

configuration.yml:

mqtt: 
  broker: myhostname.domain.com
  port: 1883
  username: mosqi
  password: XYZ

sensor:
  - platform: mqtt
    state_topic: "text"
    name: "Text"

The sensor comes up fine in the dashboard. But i cannot see anywhere, that something is trying to connect to my external broker. Is there a log file?

However, when sending messages to the MQTT broker on my local (!) HA, it displays the text in the sensor.

How would I setup 2 brokers, my external one AND the local on HA?
MQTT Broker - Home Assistant is not clear about this.

MQTT may be setup in UI

Configuration >> Devices and Services >> +Add Integration >> MQTT

I believe you only need to add the info for the external broker but depends on your purpose.

Are you only using mqtt for the single sensor?
Will all MQTT client be sending messages to “broker: myhostname.domain.com”?

The setup is, that I have two MQTT brokers:

  • external broker
  • local broker in the HA

Other external tools or sensors send messages to the external broker.
Local sensors will send messages to the local broker

I need to display the messages sent to both brokers.

Will try to setup the Integration → MQTT to the external broker.

for local use mqtt integration available from ui

for remote use mqtt eventstream

At first glance, the mqtt eventstream looks as a good solution. But I am not sure how that is supposed to work?

This looks so wrong to me:
subscribe_topic: OtherHaServerName
There is no configuration for the external broker as for hostname, the port, username and password?

Is the external broker external to your lan? ie out there on the big bad internet?

If so, do enable SSL as well as user/pw.

If not, why do you need two brokers?

Good point

Take a look at this

I don’t think HA can connect multiple mqtt sever so maybe try bridge recommended at link

External, like somewhere in the internet. Outside my LAN. On my own server. Yes, SSL and User and Password, of course.

The idea is to use the HA as message aggregator.

Oh, thanks, I have searched the forum for MQTT topics, but couldn’t find one with a solution before.

This is the most promising solution: MQTT: Working Mosquitto / CloudMQTT Bridge

Please, make support multiple mqtt sever, because mqtt now used more often

Do we have any feature request?

I used Node-Red for getting messages from a free MQTT broker on the internet into my local HA installation.

Hi @Butei,

Could you please share how you managed to do this? My knowledge about Node-Red is below zero and all I managed to do is the following:

the first item connects to the HiveMQ MQTT Broker (mqtt in) and the second one connects to the local mosquitto broker (mqtt out).
But nothing happens after the deploy. No new MQTT entity is created for my temperature sensor…

Thank you

I don’t know how helpful this is but this is my setup. I have Home Assistant Core connected to a docker mqtt broker. I then have solar assistant (with its own broker) that I also wanted to connect to home assistant. To do this, I used node red with the following:

This is the entire flow config.

The first node is the mqtt in node “Solar Assistant Create Home assistant sensors”. The topic is “homeassistant/#” and the configured broker is from solar assistant. This creates the sensors from solar assistant in to home assistant

The second node mqtt node in has the topic “solar assistant/#” and the configured broker is from solar assistant, which takes the sensor values that come from solar assistant and use it to update the sensors that the 1st node makes in home assistant

The mqtt out node just has the server set as the home assistant broker (in my case, the docker mqtt server) and it takes the topic and payload from the other 2 nodes