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?
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 }}