Detect my car by Bluetooth mac address?

Hey Everyone,

I’m trying to detect which car I’m in by the vehicle’s Bluetooth mac address in my phone app’s list of connected_paired_devices. The paired_devices list shows all possible connections with the MAC address and friendly name in parenthesis; ex: 90:E8:68:45:6B:22 (AndroidAuto-6b23). Since I may have multiple connected_paired_devices at one time, I’ll need some way to search the list for the device MAC address that corresponds to my car vs. my wife’s car. I’m sure this is easy to do, but i r dum n00b.

What sensor script would return “My Car” or “Wife’s Car” if a specific MAC address appeared as one of the devices listed in my phone’s Bluetooth connected_paired_devices?

Thanks for your help!!

{% if 'DEVICE_MAC (DEVICE NAME)' in state_attr('sensor.bluetooth_connection', 'connected_paired_devices') %}
true
{% else %}
false
{% endif %}

you could probably adapt this to a template sensor as well

1 Like

Cool, that worked! Just in case the name in parenthesis changes, is there a way to do it with just the MAC address?

Thanks again!

template:
  - sensor:
      - name: Car connection
        state: >
          {% set bt = state_attr('sensor.bluetooth_connection', 'connected_paired_devices') %}
          {% if bt is search 'DEVICE_MAC_1' %}
            My Car
          {% elif bt is search 'DEVICE_MAC_2' %}
            Wife's Car
          {% else %}
            Not connected to a Car
          {% endif %}
        availability:  >
          {{ state_attr('sensor.bluetooth_connection', 'connected_paired_devices') is not none }}
2 Likes