Notes on Issues with HA Discovery

The current implementation for HA Discovery (mqttDiscovery) works okay for single gateway setups and with only a few BLE devices. However, through comments on GitHub and my own tests, I believe that it can be improved on.

Below are a few issues/limitations that I think the current implementation needs to address.

  1. Sensors that are physically attached to OMG (IR, ADC, BME, PIR) don’t have an identifier that appears in HA that shows which OMG they belong.

    • Prefix OMG’s Short Name to the Sensor Name.
      • Should not prefix to remote devices (RF, BT)
  2. If multiple devices of the same type are found (MiBand, MiFora) there is no unique identifier to distinguish them by in HA.

    • Add BLE devices’ MAC address to the devices name.
    • OMG’s Short Name should not prefix these devices
  3. Devices not attached to OMG (BT) are not duplicated in HA. All OMG’s that receive the signal publish it in their own MQTT topic, but the last OMG that ‘saw’ the device overwrites the HADiscovery topic.

    • This means that an OMG that barely receives the signal from a device might see it occasionally, overwrite the HADiscovery topic so HA looks for the sensor reading in its OMG’s MQTT topic channel, and then never update again because the OMG rarely receives the devices’ signal.
      • Report all ‘seen’ devices to OMG MQTT topic, but only publish to the HADiscovery topic if a minimum RSSI value is met? (Only mitigates the problem, but doesn’t solve it.)
    • The closer OMG’s that always receive the signal never re-publish to the HADiscovery topic if a device is already discovered.
    • For mobile devices (MiBand), each OMG around the house will ‘see’ and overwrite each other until all OMG’s have discovered the device.
    • If an OMG that has the ‘ownership’ of the HADiscovery topic for a BT device is decommissioned, other OMG devices will never re-publish to the HADiscovery topic to try to claim ‘ownership’.
      • I’m not sure if this is solvable (at least at my level)

Do other have thoughts, comments, or feedback on HA Discovery? I’d like to have a discussion about about how HADiscovery should behave before suggesting any changes to OpenMQTTGateway.


First thank you for great work! I have also problems with Home Assistant discovery. I use ESP32 compiled for BLE. In HA I get only mi flora sensors, but no sensors for bluetooth beacons-they are scaning fine. My gateway sensor also show nothing: , only the binary_sensor is showing state.
How can I fix these?

I came here in a search for a way to make OMG to do better and unique naming of sensors.
I support both proposals for issues 1. and 2.
I don’t have an opinion on 3.

By the way, maybe this post should be split to at least two posts with more narrow topics, so each issue will have more visibility. It will be easier to solve these issues gradually/separately.