Two MQTT bokers in same configuration

I would like to use two mqtt’s one for sensors which are internal and another, cloudmqtt for external applications like presence. Obviously the cloud version could do it all but it seems more sensible to use an internal mqtt broker for internal.

Is it possible to have two mqtt’s in the same configuration?

2 Likes

I was wondering the same thing as I want to use MQTT with the harmony-api by @maddox, but I’m not sure how I would set that up for cloudMQTT. Do I have to use an internal instance? Can I use more than on MQTT instance and how do I determine which one to talk to when doing things?

I’m also asking this question in reddit. The one response I got regarding bridging brokers, which will be helpful once we know whether two instances can be run or not.

1 Like

You can setup CloudMQTT to bridge all messages to your local MQTT server.

Home Assistant is limited to 1 MQTT server.

Thanks @balloob - BTW, your talk at Pycon 2016 was great; so glad it was recorded! I really learned a lot from watching it. Thanks for all your hard work and thanks to the rest of your team!!

@Davo007 - I found this documentation on bridging CloudMQTT and it seems fairly well explained. I was able to solve my problem with the harmony-api thanks to @beanian in this thread so I am now able to get the harmony-api to communicate with CloudMQTT. Not sure if I need to do any bridging at this point but I’m going to read up on it anyways…

thanks @rpitera and @balloob bridging did the trick, and was generally pretty easy. thanks for the help.

@Davo007 - any observations you could share? It might make it easier for someone down the line…

In my case I am using a raspberry pi as the server with mosquitto as the mqtt broker. So for me it was necessary to create a conf file for mosquitto (called mosquitto.conf and located in /etc/mosquitto/conf.d) and add the following lines (some personal information has been removed):

connection cloudmqtt
_try_private false
address brokeraddress:port //this information is from your cloudmqtt server
_start_type automatic
username ha //this is the home assistant user setup inside cloudmqtt
password ha //this is the password for the associated user
clientid mqttpi
notifications false
topic dphone in 2 owntracks/dphone/ owntracks/dphone/
topic bphone in 2 owntracks/bphone/ owntracks/bphone/

the last two lines are topics subscribed to in my case it was two devices using owntracks.

Hopefully others will benefit from this experience. It was supprisingly easy once you remember that a topic that looks like this owntracks/dphone is different to a topic that looks like owntracks/dphone/

2 Likes

I’m not promising anything but would you mind if I condensed the information in this post and wrote a blog post about it? I personally hadn’t considered your solution as an option =)

I don’t see why not, providing you link this post, along with the following two links as they were all used to develop the solution.

http://e.verything.co/post/62163759361/bridging-two-mqtt-brokers

http://owntracks.org/booklet/guide/bridge/

maybe even post a link to the blog on this post too.

2 Likes

Bridging using CloudMQTT is not an option anymore if you are on the free plan.