2 MQTT on the same network

Hello,

In my factory, we have two buildings separated by a road.
The network is the same because of a wifi bridge who connect the two buildings.
I want to use homeassistant and measure temperature in the two building using only one homeassistant.
My sensors are on the technologie of MySensor.
The my choice for the gateway waas to use MQTT.
The idea is to have a MQTT in every builduings.
I make it, but it doesn’t work really good.
With only one MQTT, all is fine. But, when I connect a second MQTT on the network, I have some troubles.
With two MQTT on the network, some messages are sending to MQTT after abour 10 seconds…
Is someone have the same topology to help me ?

configuration.yaml

mqtt:
  client_id: home-assistant-1

mysensors:
  gateways:
    - device: mqtt
      persistence_file: '/home/administrateur/.homeassistant/mysensors.json'
      topic_in_prefix: 'mygateway1-out'
      topic_out_prefix: 'mygateway1-in'
    - device: mqtt
      persistence_file: '/home/administrateur/.homeassistant/mysensors2.json'
      topic_in_prefix: 'mygateway2-out'
      topic_out_prefix: 'mygateway2-in'

Be sure that the two MQTT have not the same IP.

Did you make sure that the two MQTT client (the 2 sensors) use different Client ID ?

Yes, i’ve been thinking about this issue.
This is the configuration of the first gateway :

#define MY_GATEWAY_MQTT_CLIENT

// Set this node's subscribe and publish topic prefix
#define MY_MQTT_PUBLISH_TOPIC_PREFIX "mygateway2-out"
#define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "mygateway2-in"


// Set MQTT client id
#define MY_MQTT_CLIENT_ID "mysensors-2"

and this is the configuration of the second gateway:

#define MY_GATEWAY_MQTT_CLIENT

// Set this node's subscribe and publish topic prefix
#define MY_MQTT_PUBLISH_TOPIC_PREFIX "mygateway1-out"
#define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "mygateway1-in"


// Set MQTT client id
#define MY_MQTT_CLIENT_ID "mysensors-1"

I’ve tested with same topic prefix for the two gateways, but, I’ve the same issue.

Hi,

Nobody knows?

Please help…

Hi,

I found the problem… ouf…

There is missing parameter :
// The MAC address can be anything you want but should be unique on your network.
// Newer boards have a MAC address printed on the underside of the PCB, which you can (optionally) use.
// Note that most of the Ardunio examples use “DEAD BEEF FEED” for the MAC address.
#define MY_MAC_ADDRESS 0x90, 0xA2, 0xDA, 0x10, 0xEB, 0x1D

The two mqtt ahve the same mac… Bad bad bad.
Now it work fine… Yes

1 Like