Allow core mapping mac-address to name of the Private Ble source devices

as a followup of an issue I had with the new (HA 2023.10) Private Ble devices (thanks btw, we’ve long been looking forward to that) this is a request to have core map the Mac addresses we now get on our device_trackers attributes source, to the actual names of the bt sources they connect to.

This info is readily available, as I haven been able to check for all the proxies I have setup, so it should seem feasible to have core do that for us.

now we have to create templates like:

template:

  - sensor:

      - unique_id: marijn_bt_connection
        state: >
          {% set source =
               state_attr('device_tracker.private_ble_device_9dfc84','source') %}
          {% set adapter = {'00:1A:redacted:02':'hci0 Bluez adapter',
                            '6C:94:redacted:62':'hci1 Intel',
                            'B4:8A:redacted:64':'Toaster',
                            '80:64:6F:D1:EF:DC':'Plus Plug s',
                            '24:4c:redacted:64':'bluetooth-proxy-center',
                            '24:4c:redacted:84':'bluetooth-proxy-annex',
                            '4c:75:redacted:80':'bluetooth-proxy-attic',
                            '48:55:redacted:A0':'stopcontact',
                            '0c:8b:redacted:10':'m5stack-atom-echo'} %}
          {{adapter.get(source,'Not connected')}}
        icon: >
          mdi:bluetooth-{{'connect' if
                          is_state('device_tracker.private_ble_device_9dfc84','home')
                          else 'off'}}
        attributes:
          device: device_tracker.private_ble_device_9dfc84

and do that for all devices we like to track.

we can do templates like:

      - unique_id: private_ble_device_marijn
        attributes:
          id: private_ble_device_marijn
        <<: &ble_config
          state: >
            {% from 'bt_adapters.jinja' import bt_adapters %}
            {% set device = 'device_tracker.' ~ this.attributes.get('id') %}
            {% set source = state_attr(device,'source') %}
            {% set adapters = bt_adapters %}
            {{adapters.get(source,'Not connected')}}
          icon: >
            {% set device = 'device_tracker.' ~ this.attributes.get('id') %}
            mdi:bluetooth-{{'connect' if is_state(device,'home') else 'off'}}

      - unique_id: private_ble_device_ipad_red
        attributes:
          id: private_ble_device_ipad_red
        <<: *ble_config

based on the above, which uses the mapper in a custom_template, and some yaml anchors with the this variable

still, if core would provide this, we wouldn’t need the templating in the first place, and that seems more efficient too.

please consider adding this functionality
thanks.

I’ve been thinking along the same lines. Have you had any issues with the device source not switching over? I’ll go from one room to another across the house and will still show my location as the first device with a terrible -95 dB signal strength even when right up against the second esp32.

I think it’s a great start and really hope this implementation can get up to the gold standard of Espresense.

1 Like

Thanks for posting this, this is definitely a missing functionality in the Private BLE module.

Hello,

This broke with the update 2024.1
always showing not connected
i think the ‘get’ is not working but i am not sure how to fix it
can you help please ?

Thank you

What exactly broke? Seems to still work as before here

Hello,

Thanks for the answer after some testing i noticed that i am using small letters in place of capital letters and that fixed the issue

Thanks