Presence Detector using nut (bluetooth LE tracker) and openmqttgateway

Hey,

I’m trying to setup a nut bluetooth LE tracker as a presence detector, using openmqttgateway as an intermediate device.

I can get the incoming mqtt messages:

home/OpenMQTTGateway_ESP32_M5STICK_CP_BLE_IR/BTtoMQTT/FFFF18171423 {"id":"FF:FF:18:17:14:23","mac_type":0,"name":"nut","manufacturerdata":"11020025","rssi":-86,"servicedata":"ffff18171423","servicedatauuid":"0x180a"}

I’ve configured a device on configuration.yaml with the following settings:

mqtt:
  device_tracker:
    - name: nut_1
      device:
        manufacturer: nut
        model: white
        connections:
          - ["mac", "FF:FF:18:17:14:23"]
      availability_topic: "home/OpenMQTTGateway_ESP32_M5STICK_CP_BLE_IR/BTtoMQTT/FFFF18171423"
      availability_template: "{{ value_json.id }}"
      payload_available: "FF:FF:18:17:14:23"
      json_attributes_topic: "home/OpenMQTTGateway_ESP32_M5STICK_CP_BLE_IR/BTtoMQTT/FFFF18171423"
      state_topic: "home/OpenMQTTGateway_ESP32_M5STICK_CP_BLE_IR/BTtoMQTT/FFFF18171423"
      value_template: "{{ value_json.rssi }}"
      #expire_after: 240
      source_type: bluetooth_le
      unique_id: nut_1

However, some settings seem to do nothing - I was kind of expecting the ‘value’ of the sensor to show just the RSSI, but it always shows the full json text, as if it was not extracting anything.

Also, the expire_after setting seems to no longer be supported, and the main goal of this was to default to not_home or at least unknown after not being seen for longer than 4 minutes.

What am I missing? (I have an up to date home assistant)
Thank you!

The sensor shows this, which seems to be the ‘full json’, and not the field I am interested in
image

Any clues of why the value_template is not doing anything?

If you define a simple RSSI sensor for this BLE device (without device_tracker) do you see it?

First of all thank you for your time!

Indeed it does work:

  sensor:
    - name: nut_rssi
      state_topic: "home/OpenMQTTGateway_ESP32_M5STICK_CP_BLE_IR/BTtoMQTT/FFFF18171423"
      value_template: "{{ value_json.rssi }}"

I get the expected result:
image

But is there a problem with the value_template being ignored for the device_tracker then?
Because the rssi was just an example, what I would really like to do would be to set it home when found, and not_home when a given timeout as passed, but with this new ‘mqtt device tracker’ syntax I can’t seem to find a way to do it!

This actually seems like a bug!

I’ve used the configuration on my first post, and just changed it from:

mqtt:
  device_tracker:

To

mqtt:
  sensor:

Keeping eveything else, et voilá, the value_templatedoes what is expected.
Should I raise an issue on github?

Good that you got it working!

Maybe this is not supported by the device_tracker type, not enough an expert into HASS to confirm the bug.

Hello,
I’m currently running into same issue that value_template does not seems to work for device_tracker.
However I would like to use device_tracker as it can support person’s availability.

Did you further investigated or create an issue for this?

Sorry for the late reply - no, I did no chase this further, sorry