Remember where I parked in home assistant

weird! I’ll try and check it out myself. Can you send the info when you click on the point in the map?

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.

If it stops again I’ll let you know.

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.

1 Like

Yes, please share.

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.

That is Null island

2 Likes

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:

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.

1 Like

Hello,
I’m trying to set up your tasker suggestion, but I think there is an issue in your post: the " Save Car Location profile" is not a profile, it’s a task I believe.

1 Like

Same problem here, I’m trying tasker to see if it’s more reliable

Shoot you’re right, I accidentally linked the same one twice. Sorry about that, the “Save Car Location profile” link should be updated now. It’s here for reference

Perfect, thanks!
I see the device tracker it creates has the name of the car’s bluetooth device, is it possible to change it?
The macrodroid version also has two additional things that I like: the device tracker has a picture of the car in it instead of just the round grey initials of the tracker’s name, and it also transmits the Google maps URL of the location, would it be possible to do that with the tasker created device tracker as well?

I found how to change the name and picture of the device tracker, I’m just missing the google maps link now

Yes, pretty easily actually. If you open the “Save Car Location” task you’ll see there’s just one step, a Perform Task step that calls Track Device Location. If you edit that step the first parameter is the name of the device tracker and the second is the MAC address of the device. I have the task set to pass the BT device name to the first parameter but you can change it to whatever you want.

Note that if you do this you will also need to make the same name change in the Walk to Car and Transit to Car tasks if you use those.

The task currently relies on device_tracker.see which means its limited to the parameters that service accepts. However you can give any entity a picture by customizing it. Check out the docs here to see how you can customize your entities and add a picture.

Ok so this one is an issue. Unfortunately there’s no way to do this with a custom device tracker. As you can see in the link above there’s no way to pass custom attributes like this to the device_tracker.see service. And this can’t be fixed with customization since you would want that URL to change as the latitude and longitude did.

To solve this you have two options I can see. Easiest is to simply handle this part with a second sensor. If you add this to your configuration.yaml then you can have a sensor called sensor.car_maps_url which always has the Google Maps URL for the car:

sensor:
  - platform: template
    sensors:
      car_maps_url:
        friendly_name: Google maps URL for car
        value_template: "https://maps.google.com?q={{state_attr('device_tracker.car', 'latitude')}},+{{state_attr('device_tracker.car', 'longitude')}}"
        availability_template: "{{ states('device_tracker.car'') != 'unknown' }}"
        icon_template: mdi:google-maps

A bit more difficult is to use a custom sensor instead of a device_tracker. Device trackers are a sensible concept here since you are literally tracking a device. But the device_tracker.see service is clearly a bit limited. If you want to store more info about your car then you’ll be better off just creating your own sensor with whatever state fields you want to track.

Unfortunately I don’t have a version of the Track Device Location task handy that does this. However I do have an HA set-state task that you’re welcome to use. Just like the others this task is a wrapper on an HA API, in this case it wraps POST /api/states/<entity_id>. It has the same setup as others so if you already added your API Key and Base URL you’re all set.

The task is quite simple, set par1 to the entity ID and set par2 to the JSON you want to use as its state (take a look at the docs for what that JSON should look like). Using this task you can track any state you want about your car and then use it in HA.

Side note - if you do decide to go the custom sensor route you will need to modify the Navigate to Location task if you use it. It assumes it is looking for a device_tracker type entity, you’ll need to change that to sensor.

Yeah, just noticed myself macrodroid is not relaiable :open_mouth:

I’ll move to tasker today as well :slight_smile:

Yeah something weird there. It worked fine for a while and then started missing some of the calls back to home assistant. I thought it’s related to battery saver mode, but today it happened to me with a full battery. So I guess macrodroid is just unrelaiable for this task.

I’ll be moving to tasker myself with @CentralCommand tasks and play with them a bit.
I’ll change the original post to use tasker if @CentralCommand doesn’t mind I’m using his work as a base, or delete the post if @CentralCommand wants to make a new post, so people won’t encounter the same problems with MacroDroid

1 Like

I just tried it today, and I think there is an issue with the profile: it seems to run the task periodically when it’s connected to the car Bluetooth, and stops running it when it disconnects, which is the opposite of what we want, I believe.

Also, I had a notification from tasker with a 404 error, but I still got results in home assistant.

I’ve just enabled the log in tasker to see when it runs

I have found the reason for the 404 I think: in the task you have a step called “HA get-state” that references your user in HA, which obviously doesn’t exist for me, so I adapted it.
That will teach me to just reuse code :slight_smile:

1 Like

to me it sounds like overengeineering. Why just not use navigation which remembers parking spot (like waze).

TBH I can see tendency to pack everything to HA even if it creates redundancy. Especially strange if HA solution is less matured than original one (like calendars for example). It cannot work well in the long run.

Waze does not always remember my parking location. If it does and I turn it on without using it to drive somewhere (to check how long a drive is going to take for instance), it will promptly forget where I was parked.
additionally, I don’t always use navigation. This solution is a “set it and forget it”, except when I don’t actually remember where I parked, then it’s a lifesaver.

Shoot, my bad. I spotted that beforehand and tried to replace it with a variable but I think I got sidetracked with work and then ended up exporting before saving. I just updated the task in taskernet now so from now on when importing it a new referenced global variable called HA_PERSON should pop-up for people to fill in with that entity_id.

And @Thatkookooguy sounds good if you want to replace the original details with my tasks :+1: Making a new post would split the convo so I’d rather not do that.

Which task needs to be re-imported? EDIT: figured it out - it was the “track device location” task.

And what is the entity_id it’s looking for?

I looked thru the tasks and I didn’t find any references to any “user” so I’m not sure what needs modified and to which value.

1 Like