I managed this adding the single device to the “include” section of my recorder.
I tested the automation for 2 days and I noticed that the position is not updated sometimes. Maybe it depends from my mobile…I’m thinking to add a repeat to the position so it will be updated more often.
I probably could get creative and save it to a variable if I really needed it.
But hopefully I won’t get into a situation where I need to remember where I parked my truck and in the meantime I’ve restarted HA. Seeing as I’m the only one who ever restarts HA so if I’m home (and presumably so would my truck…) and messing with HA I would have more serious problems to worry about than remembering that I parked my truck in the driveway!
Not saving the state was more of a WTH than a real need.
But I understand why device trackers don’t save the state, they are not meant to save the state. That would defeat their purpose.
When HA restarts it should update all device trackers, perhaps if you could set a “manual” attribute on them.
If that is the case then no entities in HA (aside from those controlled exclusively from within HA itself) should retain their states thru a restart. Who is to say a light wasn’t turned off while HA was down? There are many other or better examples but I hope you get my point.
We have an optional “optimistic mode” for other entities. Why couldn’t we have something similar for device trackers? I think having a “last known good location” for a device tracker could come in handy - like in the current use case.
Exactly what I’m saying.
Sensors are supposed to sense stuff, not assume.
If it retains it’s state after startup then it assumes.
Exactly my point again. HA must update states after a boot up or it will be out of sync with reality.
HA doesn’t know how long it has been off (maybe it can find it out) but giving a last known location can still be on the other side of the planet.
I would rather see “unknown” than a wild guess
But my point is that we should have the option to tell HA to assume a location based on the last known good location. It should be my choice if that’s how I want my sensor to act.
Because right now I’m forced to jump thru hoops creating variables and automations to fix the issue instead of just simply having an option in the device tracker config that says “optimistic: true” or “retain: true”.
input_* entities have that similar functionality. if there is no initial state set then it gets the same value that it had when HA shut down. So they “assume” that nothing has changed in the interim. Otherwise, to be consistent, there should be no option for an initial value or that they retain their last known state after a restart. they should always show “unknown” until programmatically updated with the desired value.
I’m sure there are other entities that act that way as well.
Of course, in a perfect world every entity would be able to be instantly polled or prompted for an update instantaneously after a restart. Sometimes (like in this particular case) that’s not possible. And in this particular case that information is lost forever with no easy way to get it back until we go back to the vehicle and connect/disconnect the bluetooth (or whatever method you are using). But if you already knew where you last parked then the whole point of that exercise is completely moot. It’s a catch-22 - you have to remember where you last parked in order to find your vehicle to set the known location in order for you to remember where you last parked.
As long as it’s an option…
But I would never use that on device trackers.
What if you walk outside your house and get a good location.
You drive away and just as you leave the house a small power dip makes your HA restart.
Ha assumes your previous position was home and unlocks the doors/alarm.
Not for me…
No…
Just save the location in a variable and use device_tracker.see to set the position according to your preference using a uptime sensor and conditions on how it should assume last position.
If I restart HA it waits for two minutes to make sure everything is up and running then it sets the car position to where it was parked.
Since I use node red it’s just two nodes that I need to add to get the function, the rest is the same as the normal sequence. I don’t find it distracting at all.
It’s so simple.
I don’t see a reason for the WTH because there is ways to do it.
Just like I would argue against premade template sensors to extract all attributes of a entity.
I would say focus on the stuff that does not work at all now and then keep these where you can make it quite easily yourself to last.
My opinion but I understand that you don’t agree.
Thanks for the code. Unfortunately it doesn’t work for me. (“Cannot call service variable.set_variable extra keys not allowed @ data[‘attributes_template’]. Got None extra keys not allowed @ data[‘value_template’]. Got None”
Perhaps it has to do with a recent update of HA. FYI I am running HA 2021.12.10.
I had to change value_template and attributes_template and remove _template from both.
Even though this is an old post I hope this helps somebody.
I’m trying to do this too.
My wife (y) and i (x) drive the car, so the automation should work for 2 phones.
I also want a button in the gui, so i can press it, and it gives me a navigation route to the point i parked the car, is that possible (not using android auto cause i want it for walking too)
Here’s my automation, but it doesnt work 100% and i have no button to navigate
I have one driver to one car and I used to have a button that navigated using Google maps but by some reason the button is not on the GUI anymore.
I believe I can figure out what the button did looking at automations and stuff.
But since you can’t get a dynamic link on the GUI (at least not with standard cards) I routed to a static php page that directed me to google maps navigation.
The automation that parks the car sends the coordinates to the same php page with a simple GET url.
Do you have a webpage you can use for this?
Hi
I’m curious how you did it.
Why do you say i cant get a dynamic link, if i just point to the device tracker as an entity i do have a link right?
I don’ t have a webpage.
Also any idea why my automation doenst always work?
I changed my host_name afterwards, might that be the cause?
CAuse in my GUI i dont see the new host name but the old one, and HA didnt make a second device tracker. (cant get rif of it either)
Old:
sequence:
- alias: "Maak device tracker aan bij start HA"
service: device_tracker.see
data:
dev_id: auto
host_name: Locatie Auto
New:
sequence:
- alias: "Maak device tracker aan bij start HA"
service: device_tracker.see
data:
dev_id: auto
host_name: Parkeerlocatie