Hi everyone, starting from June release, Template entities support the device tracker platform since device_tracker.see is deprecated. Sadly I am not able to replicate the flexibility/customizability of device_tracker.see.
E.g.:
I was able to value device_tracker.see state with output of different sensors. E.g. my wife and I have a common car, so I was populating my device_tracker.see with the gps coordinates of the last person that used that car in order to save the parking position once Androdi Auto connection dropped off. Then I was able to visualize on phone dashboard the position of the car (so no matter who parked it).
My automation was as follow (and I have the same automation for my wife Android Auto sensor that works on the same device_tracker.see):
Well, the logic I would implement is a little different: it is not basing on gps coordinate, but using the phone sensor when connected to a determined wifi network.
E.g. if the "sensor.my_smartphone_wi_fi_connection" indicates being connected to "My Home" ssid then the state of the device tracker should be "home", otherwise "not home"
Regarding the android auto based location, do note that as template device trackers do not restore state, you'll loose the state if you restart HA while the car is parked.
So if you're wife parks the car somewhere, while you are home working on HA and perform a restart, the template device_tracker will become unknown
To work around this, you could create a template sensor to store the coordinates, as the template sensor will restore state, and then use the template sensor for the template device_tracker. However, you might see there will be no need for the device_tracker, as a template sensor with a longitude and latitude attribute works quite similar as a device tracker and also shows on the map just fine.
Right now I configured it as described above, but I'll probably get rid of the device tracker soon.
This is my config at the moment:
I used trigger variables instead of an jinja if statement.
I also added an action to force a location update in the mobile app.
Logger: homeassistant.components.template.validators
Source: components/template/validators.py:39
Integration: Template (documentation, issues)
First occurred: 11:46:43 AM (24 occurrences)
Last logged: 3:56:14 PM
Received invalid in_zones: zone.test_location for entity Test Location, expected a list of zone entity_ids
Received invalid device_tracker in_zones: zone.test_location for entity device_tracker.test_location, expected a list of zone entity_ids
Received invalid in_zones: ztest_location for entity Test Location, expected a list of zone entity_ids
Received invalid in_zones: test_location for entity Test Location, expected a list of zone entity_ids
Received invalid in_zones: for entity Test Location, expected a list of zone entity_ids
The entity zone.test_location is valid, and is quite large with the exact latitude and longitude expressed in the template config.
Any ideas what I’ve done incorrectly? I have another template device tracker for my home location, and it doesn’t throw any errors.
That’s a horrible decision to remove working functionality and replace it with less reliable behavior.
I was actually caught by this.
I thought that my new template device tracker wasn’t working at all because it seemed that every time I looked at it the state was always ‘unknown’. then after I wrote up a nice long post asking for help on what I was doing wrong because it “didn’t work” I just happened to click on the “your post is similar to…” link and found this info.
Looking back at the history I do see that it kind of works tho so there’s that.
Is this going to ever be changed to be restored on a restart like the other template sensors as you suggested using?
I still don’t think things are working correctly tho so I may still need to post up a request for help anyway. I’ll have to do some more troubleshooting since I now know that I’m at least part way there.
lastly is there a way to remove the old device tracker created by the device_tracker.see service? right now I have two device trackers with the same entity_id but with _2 appended to the new templated one. And I don’t see anywhere to be able to remove that old device tracker.
If it isn’t restoring state, your template is replacing the value at startup. It was added in 2026.7 or 8, I can’t remember which version I added it in. 2026.9 added attribute templates to all entities so I think restore state was right before that
But I just checked the trace and the BT connection sensor never shows as going “un…”. And I’ve restarted several times this morning already.
I went ahead and put it in JIC as it can’t hurt.
I don’t think I’ve never seen a way to check any “traces” from a trigger template sensor is there? If not that would be nice to actually see what might be happening.
as far as the condition I agree but I think (I think… ) the template works as is for now. I may revisit that later (but probably not… ).