'Noob Question' Can you have multiple instances of MQTT (Cloud & Local) in your configuration.yaml file?

Hi All, noob to he forum so be gentle.

I currently use CloudMQTT for device tracking etc, and it works fine.
My question is: can you also configure MQTT to run locally (mosquito MQTT) on A HASS.io (pi v1.)?

and if so, how (config has one MQTT tag and not sure how you would create multiple:

mqtt:
broker: m11.cloudmqtt.com
port: 12345
username: XXXXX
Password: XXXX

all help greatly received.

Cheers
Dave.

No, you cannot have more than one MQTT broker configured at this time (that I am aware of)

You can, however, stand up a local MQTT broker, and bridge it to your CloudMQTT to get specific topics off of the cloud broker while still being able to see everything locally.

Right now I have two MQTT brokers on my NUC. One is installed directly on the Debian OS (Mosquitto) and the other is installed in Docker on the same NUC (eclipse_mosquitto). I have the eclipse_mosquitto bridged to my mosquitto as flamingm0e described so that every message that is received/sent on my eclipse-mosquiito broker is also sent/received directly to my mosquitto broker too.

But I have two HA instances as well with only one of the brokers configured on each HA.

thank you so much for he responses

how do i go about setting up and testing a bridged/broker between my cloud and local MQTT, are there any tut’s out there for this?

thanks again for the help all!

kiwi Dave.

This is a bit old, but I think the configuration is still valid.

I think this is the guide I used to get started:

http://www.steves-internet-guide.com/mosquitto-bridge-configuration/

Here is the full mosquitto.conf file i am using on the eclipse_mosquitto configuration to allow the bridge to work:

pid_file /var/run/mosquitto.pid
persistence true
persistence_location /mosquitto/data/
# Port to use for the default listener.
port 1883
log_dest file /mosquitto/log/mosquitto.log
log_dest stdout
allow_anonymous false
password_file /mosquitto/config/passwd
# user mosquitto
# Place your local configuration in /mqtt/config/conf.d/
# include_dir /mqtt/config/conf.d

#################################################
#
#           BRIDGE SETUP
#
#################################################
connection bridge-01
address 192.168.1.11:1883
topic # both 0
remote_username <myUser>
remote_password <myPassword>

You only need to set up the bridge info on one broker.

If you aren’t using an install that allows you to internally remap ports (like Docker) then you’ll need to make sure you use different ports for each broker.

In my case since I use Docker my main mosquitto install uses host port 1883 and my eclipse_mosquitto uses host port 1884 mapped to port 1883 inside the container. That means as far as each broker is concerned they both use port 1883 but to subscribe to the brokers you need top use IP:1883 or IP:1884 depending on which broker you want to connect to.