Device tracker for BT devices?

Great tips! Thanks.

I was planning on being even more sneaky and use the Bluetooth (ie audio) connection already present in the car. Unfortunately these don’t act as beacons and so they don’t show up, and the app doesn’t seem to have a sensor for “seen” bluetooth devices (presumably for battery reasons?).

Since a phone will almost always going to be connected to the car audio system I’m going to go with the bluetooth connection for now.

The final consideration is if two phones connect to a car’s audio system (or indeed see a beacon) at the same time (which seems to be possible). My naive approach was to just repeat the automation for multiple phones - multiple updates should be okay given the phones are in the same place.

But I like to do things right :stuck_out_tongue: so how can I set up the automation to only use one to copy from if both trigger? I have an If block in my head right now.

Going back a bit:

That’s interesting. In that case I go back to a previous point and suggest that this seems like something that should naturally be in the HA app - as there’s no need for the base stations to be stationary either, they just need a known (even if changing) position… which phones could easily be?

Do you have the Bluetooth sensor enabled?
It should be sensor.*phone*_bluetooth_connection

Yes I have that. What I meant by that quote is that there is no sensor for “can see but not connected to” BT devices. It may not be possible with Android’s BT implementation.

So I’ll use the Connected paired devices attribute of the sensor you gave instead.

My first try:

alias: Car Device Tracker via Mobile
description: ""
trigger:
  - platform: template
    value_template: >-
      "{{ 'MAC' in
      state_attr('sensor.phone_bluetooth_connection',
      'connected_paired_devices') }}"
condition: []
action:
  - repeat:
      while:
        - condition: template
          value_template: >-
            {{ 'MAC' in
            state_attr('sensor.phone_bluetooth_connection',
            'connected_paired_devices') }}
      sequence:
        - service: device_tracker.see
          data:
            mac: MAC
            dev_id: CAR_NAME
            gps: >-
              {{ [state_attr('device_tracker.phone', 'latitude'),
              state_attr('device_tracker.phone', 'longitude')] }}
            gps_accuracy: "{{ state_attr('device_tracker.phone', 'gps_accuracy') }}"
        - wait_for_trigger:
            - platform: state
              entity_id:
                - device_tracker.phone
              attribute: latitude
            - platform: state
              entity_id:
                - device_tracker.phone
              attribute: longitude
mode: single

This seems to work, except the device that’s created is:

device_tracker.MAC
friendly_name: MAC

Have I misunderstood dev_id: CAR_NAME? If so how to present this virtual device correctly?

EDIT: Seems providing a mac takes precedence over the dev_id, so have removed that.

Good enough for me!