I’m trying to find a way to determine the last known zone for a given device tracker. My use case: when I’m leaving work and my car is driving home (from my Tesla navigation data), I want to send a text to my partner along with my ETA.
All of this works great, except that my trigger (navigate to Home) might fire a minute late, at which point my device tracker (my car or my phone) is already “away”, not in the “work” zone.
So I’d like to look at the “Last Known Zone” instead for this info.
Best idea I have so far is to set up a template sensor with a trigger (whenever I LEAVE a zone, it updates the sensor to the zone I’m leaving). But I can’t find a suitable device type (state = zone) to create my template from?
Looking for guidance on how best to create this template sensor OR someone with a far better approach to solving this problem. In case you’re wondering, I already came at it from the other direction (trigger on leaving work zone),but run into the same problem of data not being updated yet.
I have two input_text helpers, zone_ben_current
and zone_ben_previous
, and update them as follows:
- When I leave a zone, I update
zone_ben_previous
with the value ofzone_ben_current
. - When I enter a zone, I update
zone_ben_current
with the value of my device tracker
It keeps good track of the last known zone. My use case is I want to perform some actions when going from one zone to another. When entering a zone, before updating zone_ben_current
, I can check what the last zone was and do some stuff if it was a certain zone.