Use an external MQTT

Hi,
i have 2 hassio installation: 1 for production and 1 for testing… I would like that the testing will access the production mqtt to get device data, but i don’t know how to set it up… i’ve installed the mosquitto broker addon but for what i’ve understand this will create a server in the testing machine… how can i access the production server?

thanx in advice,

Simply point your test configuration to the mqtt broker on your production server. I have both a production server and a test server, both point to the same mqtt broker.

i tryed, but I get these errors in the test machine:

 2019-09-30 13:15:23 WARNING (MainThread) [homeassistant.components.mqtt] Data in your config entry is going to override your configuration.yaml: {'broker': 'core-mosquitto', 'discovery': False, 'password': 'xxxx', 'port': 1883, 'protocol': '3.1.1', 'username': 'homeassistant'}
 2019-09-30 13:15:24 ERROR (MainThread) [homeassistant.components.mqtt] Failed to connect due to exception: [Errno 111] Connection refused
 2019-09-30 13:15:24 WARNING (MainThread) [homeassistant.config_entries] Config entry for mqtt not ready yet. Retrying in 5 seconds.

my configuration is simply:

 mqtt:
   broker: <production raspberry ip>
   port: 1883
   username: mqtt-user
   password: <my password>

On my production server:

mqtt:
  broker: 10.0.0.63
  port: 1883
  discovery: true
  discovery_prefix: homeassistant
  username: xxxx
  password: xxxx
  birth_message:
    topic: 'hass/status'
    payload: 'online'
  will_message:
    topic: 'hass/status'
    payload: 'offline'  

on my test server :

mqtt:
  broker: 10.0.0.63
  port: 1883
  discovery: true
  discovery_prefix: homeassistant
  username: xxxx
  password: xxxx
  birth_message:
    topic: 'hass/status'
    payload: 'online'
  will_message:
    topic: 'hass/status'
    payload: 'offline'  
    

Both connect fine to the same mosquitto.

But I see in your error message

'broker': 'core-mosquitto'

you are using the built-in broker

how can I tell hassio to use the external MQTT ad avoid the message regarding the ‘broker’: ‘core-mosquitto’?

thanx

Are you sure you don’t use the built-in broker on your production server ?

mmm… no, not sure… i’m not so expert… but in the production server I have the “mosquitto broker” add-on installed with this config:

{
  "logins": [
    {
      "username": "mqtt-user",
      "password": "mypass"
    }
  ],
  "anonymous": false,
  "customize": {
    "active": false,
    "folder": "mosquitto"
  },
  "certfile": "fullchain.pem",
  "keyfile": "privkey.pem"
}

and no mqtt: entry in the config file… the strange thing is that in the production logs i have:


Data in your config entry is going to override your configuration.yaml: {'broker': 'core-mosquitto', 'discovery': True, 'password': 'mypass', 'port': 1883, 'protocol': '3.1.1', 'username': 'homeassistant'}

that makes me thing i’m maybe using the built-in?

You might check this out :

thanx a lot francisp you were right, i was using built in mqtt and to change, i’ve had to edit core.config_entries! I solved my problem and now i’ve learned better how mqtt works!

Is there a “built-in” mqtt broker in HASSIO? If so, is adding the configuration the only task to enable it?
Thanks!

The ‘built-in’ broker is deprecated, and will be removed in a few updates. So don’t try to use it, it will cause upgrade problems later.