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.