This blueprint was originally made to track where I last parked my car. The idea is that it creates an entity with the gps location of my phone when it disconnects from the bluetooth head unit. This really can be used for any Bluetooth device you pair with your Android phone
To set up, it requires that you have the Android companion app and the Bluetooth Connection sensor enabled.
blueprint:
name: Bluetooth Device Last Known Location
description: Create or update an entity for a given Bluetooth MAC address with the
last location it was connected
domain: automation
input:
gps_tracking_entity:
name: GPS Entity
description: GPS entity associated with the bluetooth device used to determine
location
selector:
entity:
domain: device_tracker
bluetooth_tracking_entity:
name: Bluetooth Entity
description: Bluetooth entity used to track device.
selector:
entity:
domain: sensor
target_mac:
name: Target MAC Address
description: MAC Address of the device you are trying to track
selector:
text: {}
dev_name:
name: Tracked Device Name
description: Name for tracked Bluetooth device (Optional)
default: ""
selector:
text: {}
source_url: https://gist.github.com/dcnielsen90/e9a0a44e7b3989fc23a2a9f813ccba11
variables:
target_mac: !input 'target_mac'
dev_name: !input 'dev_name'
gps_tracking_entity: !input 'gps_tracking_entity'
new_device_name: |
{% if (dev_name == '') %}
{{ target_mac | replace(":","_") }}
{% else %}
{{ dev_name }}
{% endif %}
trigger:
- platform: state
entity_id: !input 'bluetooth_tracking_entity'
attribute: connected_paired_devices
condition:
- condition: template
value_template: |
{% set from_state = namespace(connected=false) %}
{% set to_state = namespace(connected=false) %}
{% for device in trigger.from_state.attributes.connected_paired_devices -%}
{% if device.startswith(target_mac) %} {% set from_state.connected = True %} {% endif -%}
{%- endfor %}
{% for device in trigger.to_state.attributes.connected_paired_devices -%}
{% if device.startswith(target_mac) %} {% set to_state.connected = True %} {% endif -%}
{%- endfor %}
{{ from_state.connected and not to_state.connected }}
action:
- service: device_tracker.see
data_template:
dev_id: '{{ new_device_name }}'
gps:
- '{{ state_attr(gps_tracking_entity,"latitude") }}'
- '{{ state_attr(gps_tracking_entity,"longitude") }}'
This works great but I’ve run into the issue that the location updates on my phone only happen every 15 minutes. I wonder if this could be extended to when Bluetooth connection to the car is enabled to turn on high accuracy mode and change update interval to 2 minutes. When disconnecting from car Bluetooth to disable high accuracy mode?
For me it doesn’t work. The automation doesn’t get triggered.
When I run the automation manually it works and shows the correct location of the car.
What do I have to do to trigger it?
There was a change in the app (at least for android) to report MAC address and friendly name as MAC address.
Perhaps that is the issue? I don’t use the blueprint so I can’t know for sure but that is one change that happened lately.
Thank you!
Another question: is there a way to use this with more then one driver for a car.
So, I have a car, my wife has a car, but we also drive each others cars.
Would there be an easy fix for that or would it make things very complicated?
What do you use as the GPS entity? I use life360 and it just uses my areas “Home”, “Work” and if it’s somewhere that it’s not one of my areas it just says “Away”
I implemented something similar in node red prior knowing this blueprint and ended up having the same problem. It’d be nice to be able to implement automations running in the companion app or, as you suggested, being able to switch the 15mins to some lower value and then back to 15mins to save battery.
I ended up using NFC tags in the keys. When we park we scan them and the location is stored.
Of course we forget sometimes…
BTW. 2 more things I did in node red which are a nice addition to this blueprint.
A Gmaps shortcut to open it with the saved coordinates.
I store the name of the street and nr from the phone location so when we park close home you recognize the name of the street and it’s quicker.
I can clean it and share it if someone is interested but no Bluetooth trigger. Only NFC tag
I made a very similar automation, but I made the trigger the template of the devices mac not being connected. It eliminates the need of having the bluetooth device sensor to start with.
But I’m no good at blueprints, so I had to do it the long way with multiple triggers and trigger id’s and individual actions.
## [Focus en Maps](https://www.google.com/maps/search/{{states('input_text.cfg_avisos_ubicacion_coord_aparcamiento_focus')}})
For this to work, you have to store your latitude and longitude in the variable “input_text.cfg_avisos_ubicacion_coord_aparcamiento_focus” so the end link looks like this: https://www.google.com/maps/search/40.419332,-3.693110
(Don’t worry, I didn’t park my car in Cibeles, hehe)
I implemented it in nodered. When I scan the NFC Tag I trigger a few things and one of them gets the geocoded location from my phone and stores it in the variable.
Here are some screenshots. I’m not used to share stuff here so my explanation might be a bit messy, sorry in advance.
I did something similar with the thoroughfare and sub_thoroughfare which gives you the name of the address and it’s very useful to remember where you parked if you know the name of the streets around your house.
I made a fork of this that will also track non-paired devices.
Useful for accessories that connect directly to an app like Trakr Pixels, the Pokemon Go Plus+, and other similar devices pair to an app directly and don’t ever show up in the phone’s paired devices list.