This means that I park my car at a different location at the start of every weekend, and forget where I parked by the start of the week
I have several options to remember where I parked automatically:
Tell google assistant to âremember where I parkedâ
need to actively remember to do this
Look at my timeline in google maps to see my last driving location
Since I do several overlapping laps before I find a spot, itâs not easy to spot where I stopped the car on the map because of overlapping lines
Have some automation to do this for me
Implementation
Prerequisites
Home Assistant of course
hass-variables - allows us to create a last_parked variable that will hold the car location
MacroDroid - Allows you to create automation based on disconnecting from a specific Bluetooth device
RESTask for Tasker - Allows you to send POST requests. Even though this is a Tasker Plugin, MacroDroid can communicate with this plugin directly, so Tasker is not needed for this to work.
Algorithm
MACRODROID
Whenever I disconnect from the carâs Bluetooth (in my case, KIA_MOTORS), save my phoneâs location to a global variable
Whenever a new last parked location saved, send a post request to home assistant with the device location as the body using the webhook endpoint (<hass.io>/api/webhook/last-parked)
HOME ASSISTANT
Whenever a last_parked webhook is received, save the map URL, longitude and latitude to our variable in home assistant
Home Assistant Automation
Create the following variable in your configuration:
Actions: Go to LocationShare Location and select Variable from the pop up window. Select lat,lon and create a new variable called parkingLocation. Do this again, creating another action, but select Google maps link and name the variable parkingMapLink
Action: Go to ApplicationsLocale/Tasker Plugin and select RESTaskRESTask Event. In RESTask, change the following fields:
under Settings:
change Request Type to POST
change Host to your home assistant webhook URL: <home_assistant_url>/api/webhook/last-parked
under Parameters:
Click on Add more to create a new parameter. set the name to parkingLocation and the value to [v=parkingLocation]. You need to type this manually. This will connect the global variable we created in MacroDroid to RESTask.
Create another parameter for the parkingMapLink following the above step.
Save the RESTask command you created, and click on OK in macrodroid. You can test that everything works by entering the Remeber where I parked macro, clicking the three dots, and selecting Test Macro
RESTask also requires Tasker to be pre-installed for this to work?
You donât need tasker installed. Macrodroid can work directly with the plugin.
When you create a new macro and select your action, open Applications, and there, click on Local/Tasker Plugin. when youâll select RESTask, it will open up restask where you can set the specific request you want to make
Cool! Let me know if you need any help. I had a few hiccups on the way which I hope you wonât go through if you set up everything as described above, but I might have missed something.
And if everything worked, I would love to hear about that too
Also notice that in my macros I have some disabled steps (will remove them from the screenshot soon), so you donât need to add those (the ones that are a little grayed out)
Iâve gotten to the point of adding the actions to macrodroid and I have a question (or twoâŚor three)
What do you use for the title and message for the âDisplay Notificationâ action? The screenshot only shows one variable. Do you use one variable for the title and one for the body or do you use the same one for both?
Where do you find the âExecute HTTP shortcutâ action? and where does the âtestâ shortcut get created?
When filling in the RESTask parameters should I need to fill them in manually or should they be presented as an option to select from somewhere?
What do you use for the title and message for the âDisplay Notificationâ action?
The notification here is just a phone notification (on the phone itself, not home assistant). you can skip this if you want. I just put in the body of the message the mapLink but didnât do anything more with it since I used it for debugging mostly. The title of the notification for me is just Car Parked.
Where do you find the âExecute HTTP shortcutâ action? and where does the âtestâ shortcut get created?
I have some disabled steps in my macros (will remove them from the screenshot soon), so you donât need to add those (the ones that are a little grayed out). This was a failed attempt to do the HTTP request with another tool. Skip that step sorry for the trouble
When filling in the RESTask parameters should I need to fill them in manually or should they be presented as an option to select from somewhere?
I entered the details manually inside RESTask. The parameters I filled were
METHOD should be POST
url should go to your home assistant instant <url_to_ha>/api/webhook/last-parked
parameter should include the two global parameters set in macrodroid. the name of the parameters should be parkingMapLink and parkingLocation (same as the ones defined in macrodroid. this is not mandatory, but I kept the same naming convention across all applications). The value should be [v=<macrodroid_parameter>]. I entered this manually, and this is how you inject the value from macrodroid to this tasker plugin.
I see this is far less clearly written than I thought. Iâll fix the original post to reflect most of what was discussed here
I was wondering if this could be done solely with Tasker?
You can. You need to create a profile that is active when connected to the Bluetooth device and set up an exit task to run whatever you want when the profile becomes inactive due to the device disconnects.
Since I didnât have any automation using tasker or macrodroid up until now, it sounded a little easier to do with macrodroid.
But if you do create this with Tasker alone, please share it
Thank you so much, Iâve had this issue for a while, especially in lockdown where I took my car about 3 times in 2 months, I always forget where I park it!
Juste tested it with a bluetooth headset, seems to work perfectly well!
Yeah, this problem became bigger for me as well now with Covid-19. Thatâs why it became so essential.
I drive so little now, itâs even harder to remember where I parked lol.
Iâm not really sure whatâs going on but now that Iâve had time to test it for a couple of days I seem to not get a good GPS position when I disconnect.
For example right now it says my car is parked off the west coast of Africa.
Iâm not sure why it was doing it but I went into macrodroid and clicked around on a few of the settings in the macros and when I tested it again it now seems to be working.
As far as the point on the map it was at 0 latitude & 0 longitude so obviously the coordinates werenât getting updated correctly. But also the persistent notification wasnât being triggered either even tho it was sending the update action in the webhook.
It was definitely strange but it seems to be working again for now.
I do this too! I also keep track of my bluetooth headset this way. Although admittedly its not exact enough to tell me where in the house they are, more like are they in the house or did I leave them somewhere else.
I donât use hass-variables, I used to but then I found you can make custom device trackers using device_tracker.see. Itâs basically the same process I just call the device_tracker.see service from tasker after doing a get location call on disconnect from the bluetooth device Iâm tracking.
Also for the car instead of using âbluetooth disconnectâ as the event I use âbluetooth near becomes falseâ. I do this because my wife and I often drive together and only one of our phones connect. Bluetooth near immediately becomes false when the car is off so effectively this is the same trigger except it doesnât matter which of our phones actually connects to the car.
Another neat trick I added is I created a task that i can use as a shortcut on my phone called âNavigate to carâ. When I run the task it uses the get state API to get the last known location of my car from HA and then launches google maps navigation in walking mode with directions from my current location to my car.
I do actually use Tasker for all this so I canât really share exports for you, Iâm not familiar with MacroDroid. Looking at your screenshots it seems like they fulfill similar purposes so Iâm sure these can be recreated there. If someone wants me to share my tasker exports let me know though.
Ironically right after I posted above that things were working again I noticed that the automations didnât run when I got to work. It seems that macrodroid isnât very reliable for some reason - at least on my phone.
So Iâll share everything you need here but at the very base of these is essentially this package. Granted I adjusted that authors tasks a little bit as you can see further down in that thread here but thatâs the base package used for communicating with HA. Iâm going to share my versions of those tasks but you should also be fine just using the originals if you prefer or already have them.
For basic HA communication youâll need these 4 tasks:
To make these work you just need to fill in the two global variables referenced in them. Put your Home Assistant URL in %HA_ADDR and a long-lived access token in %HA_TOKEN.
Then for car tracking youâll need these two tasks and the profile that triggers them:
Once you import these youâll see two new referenced global variables to fill in. Put your carâs bluetooth name in %CAR_BT_NAME and its mac address in %CAR_BT_MAC. Then whenever your phone goes from being near the carâs bluetooth to not near it will stash its location in HA. It does this using device_tracker.see so its a custom device tracker. The Bluetooth name will be used as the tracker name.
Then finally the last 3 tasks are shortcuts you can put in your home screen or quick tiles menu to immediately launch into navigation mode and navigate to your car:
Navigate to Location task (note this one isnât intended to be run directly, itâs a dependency of the other two)
And thatâs it, should be good to go. If you take a look youâll see that all the real logic here is in Track Device Location and Navigate to Location which both take the device ID as a parameter. This way if you want to track other bluetooth devices (like I did with my headset) its very simple. You can clone the other tasks and just replace CAR_BT_NAME and CAR_BT_MAC with the name and mac of some other device.
One FYI though - I do depend on the Tasker add-on AutoTools. I basically just use it for JSON processing so you can get by without it but. youâll need to change some things. Taskerâs OOTB JSON handling options are a lot more difficult to use unfortunately.