MQTT Bridge

Hi

I am using Owntracks with Cloudmqtt , I would like to use a local broker.
I have read somewhere that you can use Mosquitto and bridge to CloudMQTT.
As always I find numerous posts on semi relative advice, and vague guidelines.
Being a novice with HA is there any form of tutorial out there which can guide me to achieve this?

Thanks

Meganoodle

1 Like

I’ve done that and its pretty simple. If you already have CloudMQTT running you just need to install Mosquitto and then set up the bridge like this: MQTT: Working Mosquitto / CloudMQTT Bridge

Use mosquitto_sub to see if messages arrive correctly on mosquitto.

I had cloudmqtt setup with our phones as trackers on owntracks, and it worked setup directly with my HA server.
But I want to introduce my home made nodemcu sensors via a private mqtt broker.
So I have followed these instructions as you advised.
https://community.home-assistant.io/t/mqtt-working-mosquitto-cloudmqtt-bridge/1830

And pointed HA to mosquitto, all I get is my local sensors, nothing from cloudmqtt, not even a file named known_devices.
Im sure its me, Ive tried alternative tracker apps cant get those to work either. I enjoy a challenge, but this is getting to be as enjoyable as getting my teeth pulled.

1 Like

im having same issue. did find a way to bridge cloudmqtt and mosquitto?

Yes I carried out the instructions according to the link above.
Then I eventually found on the cloudmqtt console, below instances and above Manage users there are 3 tabs.
Click the ‘Bridges’ tab
and under ‘New Bridge’ fill in the details of your Mosquitto server and select in/out or both.

It worked perfectly for me.

1 Like

Hi
I am using Home Assistant on a raspberry pi 3 with let’s encrypt on it.
I tried to set the bridge on CloudMQTT to send the messages from owntracks to my own mosquitto server.
I can see information from owntracks in my CloudMQTT but nothing comes in my local server.
In the bridge i added: mqtt://user:[email protected]https://xxx.duckdns.org:1883 i even forward the port 1883 to the pi local address but no message is received in mqtt.
If you can share how you made it work will be much appreciated.
Thanks

Take a look at the thread that was linked to above. It details how to bridge from your local Mosquitto install to a remote CloudMQTT instance. If you do that, and it’s working, you’ll get the required data in your local Mosquitto instance.

When using TLS/SSL you need to use port 29814, not 39814 for the remote bridge port.

Thanks for your response. Unfortunately i hit again the same problem that i had previously wen attempted to set mqtt.
Now after adding the file in the conf.d folder my mqtt will not start and in Home Assistant i receive a invalid config card.
So i have no idea what to do now.
So i added:

connection cloudmqtt
address <m12.cloudmqtt.com>:<29744-my ssl port>
remote_username
remote_password
clientid
try_private false
start_type automatic
topic # in

sorry for some reason the address is not displayed here correct so is m12.cloudmqtt.com with < >
Let me know if you have any idea.
Thanks.

Well, if you’d posted it with the preformatted text formatting (</>) rather than as a quote, things would have been easier to read. I suspect your problem is because you didn’t configure it correctly for SSL - there’s no bridge_cafile configured:

connection CloudMQTT
address m00.cloudmqtt.com:SSL_PORT
remote_username USERNAME
remote_password PASSWORD
remote_clientid CLIENT
try_private false
start_type automatic
bridge_cafile /etc/ssl/certs/ca-certificates.crt
topic # in

hello @meganoodle I bridged under Cloud MQTT configuration. selected both in/out. Local prefix and Remote prefix I left blank. bridge works but whenever I send an MQTT message to through Mosquitto broker or directly to Cloudmqtt. under Websocket UI received messages each message will be twice. I’m I doing something wrong?

Ashfaa Im glad you got it working, from what you have described you have done it seems right.
My mqtt seems to be behaving perfectly.
Im afraid I dont know what might be wrong .
What have you put into your local mqtt config file?

Hi all
I just manage to connect the cloudmqtt bridge with my mosquitto server i receive the updates from owntracks on the topic oqntracks/phone/phone .
I manage to extract the battery level But i don’t know if the location is working or not since i cannot see anything on the map. Could be because i am home.
I do have few errors in to the bridge connection on cloudmqtt log
1490231154: mosquitto version 1.4.10 (build date Thu, 25 Aug 2016 15:32:03 +0100) starting 1490232954: Error saving in-memory database, unable to open /var/lib/mosquitto/19744/db.new for writing. 1490232954: Error: Disk quota exceeded. 1490233517: Error in poll: Interrupted system call
Although i can see in the local mqtt that the message with location is received and battery level is displayed in HA.
If anyone can help me with this or point me in the right direction will be much appreciated.
Thanks

i dent change anything on my local mosquitto mqtt config file

it wont show your icon on the map if you are at home. If you have access to your home assistant outside of your network (IE DUCKDNS and LETSENCRYPT and port forward) when you leave home check it from your phone by looking at the MAP (menu on the right hand column.)

Thanks for your response.
Just an hour ago i had the confirmation that is working and quite well.
Now to create automation for it.
Although i continue to have errors in the cloudmqtt log:
1490201538: Connecting bridge http (http:1883) 1490201538: Error creating bridge: Name or service not known.

Thanks for all the help.

How odd!
If I understand correctly (although Im nowhere near an expert) your mqtt shouldnt be working.
I wouldnt know unless I saw your mqtt setup in your home assistant config (blank out sensitive data) even then I may not be able to help.
Which mqtt is your home assistant pointing too? local or remote?

Checklist.

Setup DUCKDNS and LETSENCRYPT

https://home-assistant.io/blog/2015/12/13/setup-encryption-using-lets-encrypt/

Follow the instruction from this link to setup your local mosquitto.

https://community.home-assistant.io/t/mqtt-working-mosquitto-cloudmqtt-bridge/1830

Make sure your cloudmqtt bridge points to your local MQTT (an address like this).

mqtt://USER:[email protected]:1883

Make sure you have forwarded port 1883 to your Mosquitto PI?

1 Like

Hi all, is there any benefit to using cloudMQT as a bridge to a local MQTT broker, maybe security? Why not just open up a port forward and link Owntracks direct…?

I would be interested to find out how you managed that.
When I tried, all the tracked phones seem to have the same ID or at one stage it would only track one phone.
It may be an issue with my ISP (Virgin Media), it messes with my ports, and I am limited with the port forwarding also.
Will be getting a new router soon (or get a different ISP) .

I’m using a bridge so I don’t have to expose my MQTT broker to the Internet. External devices can talk to a CloudMQTT instance, and everything internal can talk to the internal broker. Why increase the risks if you don’t have to :wink:

2 Likes

Check the OwnTracks configuration on each device. You should have separate accounts on the MQTT server for each phone.