Multiple ble_tracker listeners for Xiaomi Mijia senors?

I’m using xiaomi_ble sensors with esp32_ble_tracker. Currently, I have each Xiaomi sensor associated with the closest ESP32. Is there any way to have multiple ESP32’s listening to the same beacons such that the sensor status is reported regardless of which ESP32 is receiving the beacon sensor data?

I can imagine a way to do this via MQTT, similar to how ESP32-mqtt-room aggregates multiple BLE sensors but before I head down that path I’d like to know how others are handling distributed BLE receivers.

Cheers,
Eric

Only way I’ve found is to use a Template sensor. It just looks at the entity from both BLE devices and grabs the newest value.

- platform: template
  sensors:
    sub_basement_humidity:
      friendly_name: "Sub-Basement Humidity"
      unit_of_measurement: '%'
      device_class: humidity
      value_template: >
        {% if states.sensor.sub_basement_humidity_sbble.last_changed > states.sensor.sub_basement_humidity_mbble.last_changed %}
          {{ states('sensor.sub_basement_humidity_sbble') }}
        {% else %}
          {{ states('sensor.sub_basement_humidity_mbble') }}
        {% endif %}
1 Like

I’m currently trying to list multiple sensors per esp32 trying to capture up to 6 sensors.
I’m not sure what is happening but my succes is not 100% … are there guidelines on what is possible?
In the logs for example I do see the sensors report on the temp - and being send - yet in home assistant no temps are visible for these sensors…

This is what I landed on

template
  - sensor:
      - name: "Basement Humidity"
        unit_of_measurement: '%'
        device_class: humidity
        state: >
          {{ expand('sensor.basement_humidity_1', 'sensor.basement_humidity_2', 'sensor.basement_humidity_3',) 
          | rejectattr('state', 'in', ['unknown', 'unavailable']) | map(attribute='state') | first }}
        availability: >
          {{ expand('sensor.basement_humidity_1', 'sensor.basement_humidity_2', 'sensor.basement_humidity_3',) 
          | rejectattr('state', 'in', ['unknown', 'unavailable']) | map(attribute='state') | first | is_number}}

I wanted to do the same thing as the OP (have multiple listeners without multiple devices in HA). Found that the custom Passive BLE Monitor integration has added support for what they call “BLE Gateways”. So you can now make any number of ESPHome devices listeners/gateways and feed back into that component centrally. Works pretty well, you can add as many listeners as you want and only have a signal entity in HA per real sensor.

https://custom-components.github.io/ble_monitor/parse_data

Openmqttgateway handles multi esp32 receivers natively and will create only one unique device in home assistant per sensor.
You can also add Theengs gateway (server ble2mqtt) on your raspberry pi or other server and it will leverage the same device in home assistant.
https://theengs.github.io/gateway/

So multiple esp32, multiple Pi, one device created in HASS per real device.