[solved] Local Mosquitto broker - CloudMQTT bridge

This file would be inside docker which is kind of small virtual machine. You’ll need to

  1. SSH to host
  2. View running containers docker ps
  3. Find Image Id of your container (local/mosquitto something)
  4. docker exec -it <container id> bash

Another option is to change location of your conf file and to serve it from, for example, share folder (refer to hassio documentation describing linking folders)

1 Like

It seems I’m having difficulties with the second step already.
I followed xbmcnut’s tutorial here for setting up ssh.

Judging by ASCII-art it’s not a host ssh, but rather ssh add-on you’ve installed :slight_smile: You need connect to resin itself https://home-assistant.io/hassio/debugging/

1 Like

Hey @vkorn,

I’m using a windows machine, so except the boot partition I cannot access anything if I put the sd card into my reader. Do you know any solution to get the public key onto the root partition?

You won’t need anything. To enable ssh you have to drop key into the /boot partition

1 Like

So, I managed to modify it and get it running properly, big thanks to @vkorn!
If anyone is interested, here is the repository.

This is an example Options configuration:

{
  "plain": true,
  "ssl": false,
  "anonymous": false,
  "logins": [
    {
      "username": "Testuser",
      "password": "testpw"
    }
  ],
  "certfile": "fullchain.pem",
  "keyfile": "privkey.pem",
  "bridges": [
    {
      "connection": "cloudmqtt",
      "address": "cloudmqtt.com_address:port",
      "remote_username": "bridge_testuser",
      "remote_password": "bridge_testpw",
      "clientid": "HomeAssistant",
      "try_private": "false",
      "start_type": "automatic",
      "topic": "# in"
    }
  ]
}

It is possible to create more than one bridge.
Maybe someone can test it and merge it with the official addon (I’m not a programer)?

This did not work for me… any thoughts?

You don’t need it anymore. It’s now implemented in the official mosquitto broker plugin.

check https://home-assistant.io/addons/mosquitto/ for further details

What should the ‘clientid’ be? Can it be anything? I’ve used ‘hassio’ but I get the following error when in MQTT.

starting version 3.2.2
1502536497: mosquitto version 1.4.12 (build date 2017-06-01 13:03:48+0000) starting
1502536497: Config loaded from /etc/mosquitto.conf.
1502536497: Opening ipv4 listen socket on port 1883.
1502536497: Opening ipv6 listen socket on port 1883.
1502536497: Warning: Mosquitto should not be run as root/administrator.
1502536497: Connecting bridge cloudmqtt (m11.cloudmqtt.com:11576)
1502536498: Socket error on client local.hassio, disconnecting.
1502536528: Connecting bridge cloudmqtt (m11.cloudmqtt.com:11576)
1502536528: Socket error on client local.hassio, disconnecting.

I can log on to m11.cloudmqtt.com:11576 using MQTT.fx so I know the connection and account is OK.

Do you have an exposed port so that it can connect?

Not sure what you mean? I’m getting the local MQTT add-on trying to connect to a remote CloudMQTT instance using the customize option. I have no outbound port firewalls.

I’m not at home right now, but in cloudmqtt you’ve to create a new user with access rights to the topics you want to sync. I used this user as my client id

I created three users and I tried using the name for the first user as the clientid and I get the same error.

Hello all, I added the MQTT addon to Hassio, and my options currently look like this:

{
“plain”: true,
“ssl”: false,
“anonymous”: true,
“logins”: [
{
“username”: “username”,
“password”: “password”
}
],
“customize”: {
“active”: false,
“folder”: “mosquitto”
},
“certfile”: “fullchain.pem”,
“keyfile”: “privkey.pem”
}

I then added this to my config:

mqtt:
broker: 172.17.0.1

I then saved it, restarted the addon and rebooted the Pi. How can I tell if it is running properly? I am trying to set it up to get an addressable LED strip working through Hass (from Ben’s video).

Thanks!

Download MQTT.fx, it’s a life saver. Create a connection to your broker using the IP, username and password you set and then subscribe to # (everything). You can then use that to publish commands and to see what is happening at the broker. Great tool if you’re not into the command line stuff.

1 Like

Wondering if you can confirm your config for me? If I use CloudMQTT as my broker (instead of the local IP) I connect to CloudMQTT and see that my position reported by Owntracks is being updated. If I then revert to the hassio MQTT add-on with a customize option using the same credentials as before (but now in a conf file), I get socket errors and disconnection.

Hey @xbmcnut,

this is the config in the mqtt addon:

{
  "plain": true,
  "ssl": false,
  "anonymous": false,
  "logins": [
    {
      "username": "REDACTED",
      "password": "REDACTED"
    }
  ],
  "customize": {
    "active": true,
    "folder": "mosquitto"
  },
  "certfile": "fullchain.pem",
  "keyfile": "privkey.pem"
} 

This is my *.conf file (located in share\mosquitto)

connection cloudmqtt
address REDACTED
remote_username me-Hassio
remote_password REDACTED
clientid me-Hassio
try_private false
start_type automatic
topic # in

And these are the users for owntracks

2 Likes

Thank you. It seems I have the same but the logs for MQTT give me this:
1502922011: Connecting bridge cloudmqtt (m11.cloudmqtt.com:http_port)
1502922011: Socket error on client local.hass, disconnecting.

Here is my MQTT config:
{
“plain”: true,
“ssl”: false,
“anonymous”: false,
“logins”: [
{
“username”: “pi”,
“password”: “raspberry”
}
],
“customize”: {
“active”: true,
“folder”: “mosquitto”
},
“certfile”: “fullchain.pem”,
“keyfile”: “privkey.pem”
}

Here is my cloudmqtt.conf located in \localipaddress\share\mosquitto

connection cloudmqtt
address m11.cloudmqtt.com:http_port
remote_username hass
remote_password xxxxxxxxx
clientid hass
try_private false
start_type automatic
topic # in

And the user I set up in CloudMQTT (I have another user for my phone which connects and the CloudMQTT console shows my location being updated.

Can you share your logs for the MQTT add-on? Unless I’m staring at a glaringly obvious typo I can’t see, my config appears to be the same as yours?

P.S Did you add a bridge back to your local HASS instance in the CloudMQTT console as I see some mentioning that?

If I remove the local MQTT instance in my configuration.yaml and add CloudMQTT instead with the same username and password, HASS connects and reports my phones location so something a bit nuts.

1 Like

@tillmannschatz My BAD!!! I had the @#@#$%^%^ CloudMQTT address wrong! I had m11.cloudmqtt.com instead of m13.cloudmqtt.com even though I’d recorded the correct address in my network database. Argh. That’ll teach me for trying to do home automation at 1130 at night. Thanks for sharing your config and for your patience.

:joy:
that happens, no problem