Remember where I parked in home assistant

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

Yea you got it, it was Track Device Location, sorry was on a call. There should be a new global variable for HA_PERSON now. It uses your state to set the state of the device tracker since there’s no way for tasker to know which HA Zone you are in and HA does not use the latitude/longitude information to determine that for custom device trackers.

So the entity_id it needs is my “person.me” entity from HA?

Yes, that’s the one. You can also give it the entity id of the device tracker for your phone if you prefer. It doesn’t enforce that its a person.* entity, it just wants something to set the state of the tracker from.

1 Like

@CentralCommand I changed the profile to “bluetooth connected” rather than “bluetooth near”, as it started the task during my drive rather than when I parked. I’ll comment back if it helps.

I have another question: if I restart home assistant, the location is lost, is there a way to make it persistent between restarts?

Also, I noticed that you always send 100m in the “gps_accuracy” field, even though tasker has a variable with the accuracy available.
I have adapted your task to send tasker’s accuracy measurement, so that the circle in HA is not so huge, it should work the same as you:
Updated “Track device location”

Hm ok. Yea I thought I was actually having better success with BT near then BT connected but I’ll keep an eye on it. If you’re phone is the only one that connects to the car then BT connected is the way to go. In my case sometimes my phone is connected and sometimes my wife’s is so I switched to BT near to try and keep tracking even when my phone wasn’t the one directly connected.

Is that what that is? I actually didn’t know, I thought it was a percent lol. That totally makes sense though. I remember in my testing I was getting really confusing readings from Tasker’s Location Accuracy variable and so I just put 100 in and figured I’d come back to it if it caused an issue. Thanks!

Ah crap, I forgot about this. Unfortunately there’s no OOTB way to do this. I remember discovering this and creating a feature request for it. I do have a workaround but it involves Node RED. Basically what I do is any time the device_tracker.see service is called, Node RED picks up on it and stores that info in a sensor it creates. Then on HA start-up it calls device_tracker.see for each data backup sensor.

If you have Node RED I can share my code with you. You’ll have to change the sensor names but its pretty straightforward otherwise.

If you don’t have Node RED you can build restore functionality using two automations and the variables custom component. With that component you just need to add this:

variable:
  car_tracker_backup:
    restore: true
    value: home
    attributes:
      friendly_name: 'Car tracker backup'

automation:
- id: backup_tracker_data
  alias: Backup custom device trackers
  description: Use a variable to persist custom device tracker data across resets
  trigger:
  - entity_id: device_tracker.car
    platform: state
  condition: []
  action:
  - service: variable.set_variable
    data:
      variable: car_tracker_backup
      value_template: {{ trigger.to_state.state }}
      attributes_template: >
        {
          "source_type": "{{ trigger.to_state.attributes.source_type }}",
          "latitude": "{{ trigger.to_state.attributes.latitude }}",
           "longitude": "{{ trigger.to_state.attributes.longitude }}",
           "gps_accuracy": "{{ trigger.to_state.attributes.gps_accuracy }}",
           "host_name": "{{ trigger.to_state.attributes.friendly_name }}"
        }
- id: restore_trackers_on_startup
  alias: Restore custom device trackers
  description: Restore data for custom device trackers on startup
  trigger:
  - event: start
    platform: homeassistant
  condition: []
  action:
  - service: device_tracker.see
    data_template:
      dev_id: car
      host_name: "{{ state_attr('variable.car_tracker_backup', 'host_name') }}"
      location_name: "{{ states('variable.car_tracker_backup') }}"
      gps:
      - "{{ state_attr('variable.car_tracker_backup', 'latitude') }}"
      - "{{ state_attr('variable.car_tracker_backup', 'longitude') }}"
     gps_accuracy: "{{ state_attr('variable.car_tracker_backup', 'gps_accuracy') }}"

Also alternatively since this requires the variable component anyway you could just track the car location using restorable variables and drop the device trackers. Just basically switch the service call on taskers side from device_tracker.see to variable.set_variable and adjust the parameters accordingly.

I can’t really think of any other options unfortunately. Other then upvoting the feature request and hoping custom device trackers get native restore.

1 Like