Interesting. I thought this was kind of a silly WTH but it turned into an interesting discussion on estimating ETA so I guess I’ll add my two cents. Ever since I realized Nest had an ETA API I’ve been trying to crack this one. Rather then when to start making coffee my goal has been “when to turn off eco mode so my house is the right temperature when someone arrives home”, same idea different goal task. My setup isn’t perfect but I have gotten it pretty good at this point. Here’s I guess a summary of what I learned and some tips from my setup:
1 - You’re not going home until after you arrived somewhere
I mean usually. Yes in some cases you simply take a lap or something (maybe trying to put a baby to sleep). But this is an edge case. Most of the time it’s safe to assume no matter which direction you go in you aren’t going home until you got somewhere.
I should note that this is one place where the different goal task does make a difference. Because I’m trying to figure out when to start heating/cooling the house that means even if I’m taking a run or something there’s no ETA if someone else is still home, I only care about ETA when no one is home. So its really rare for all of us to leave and not reach a destination before coming back. If you are focused only on one person then it might be less of an edge case that they come home without first reaching a destination.
So for each person I have an “arrived at destination” switch. After the person leaves the house this flips on if:
- The person arrives at any zone
- The person’s phone connects to wifi (this one may not work for you if you use a lot of hotspots)
- The person’s movement speed is walking or below for 5 minutes (unless walking is their expected mode of transit then it has to be stopped for 5 minutes, more on this in a second)
2 - Ignore dir_of_travel
in proximity (or the concept in general)
I saw this mentioned earlier so I’ll mention it here, this isn’t really helpful IMO. It sounds like it should be good but it’s not. Roads are weird. They go in all sorts of strange directions especially when you need to connect from one major road to another. You’ll often be briefly going in the direction of your house multiple times on your journey. At least that’s my experience, if you are far outside any city and rarely go into any densely populated areas maybe this works better for you since I imagine roads are more predictable. But in my experience there was so much bad trigger noise trying to figure out when I was getting closer to the house for real vs. just briefly.
Focusing on destinations works much better in my experience. Assume once you get to a destination you are going home any time you leave one unless and until you stop at another. Regardless of where the route actually takes you.
3 - The detected_activity
sensors from mobile_app
are really good!
I spent a while mucking around with proximity sensors and the speed
attribute on the device trackers from mobile_app
trying to figure out my mode of transit based on how fast I was moving. I never really got it right. But these detected activity sensors are really excellent at it, just use them.
A few tips I’ve figured out with this:
- Make a select or something that starts at
Walking
when you leave the house and only goes “up”. So like once you see Cycling
as the detected activity then it can never go back to Walking
until you go home again. And once it sees Automotive
then it can’t go back to Cycling
or Walking
. This is important because you don’t want traffic to affect your ETA just because you’re temporarily moving at Walking
speed. If you left the house driving you’re almost certainly driving home.
-
Unknown
is super obnoxious. You can’t assume they’re stopped or that they’re still in the last state. Phones report Unknown
whenever they aren’t confident of the activity and don’t tell you how confident they are. What I do is have my template entity fall back on the speed
attribute in the device tracker and try and guess activity from that when it sees Unknown
. But mostly you just kind of have to ignore it.
-
Transit
can’t be predicted from this. My suggestion is to pick a location that if you go through you are definitely using transit and make a hidden zone there. Then if you see a zone entered event for that zone set the expected mode to transit and don’t let it change.
Obviously this whole section only applies if your mode of transportation varies. If you’re always driving you can ignore all this. But sometimes I bike or use transit to go places so my setup has to guess the ETA according to my mode of transportation.
4 - Travel time sensors to figure out the ETA
I use the google maps travel time sensors. There’s also something called a here travel time sensor and a waze one. Haven’t tried these two but assume they work fine as well.
To avoid going over the quota and paying money, set the scan interval arbitrarily high and call homeassistant.update_entity
on it. I have one of these sensors for each person and each possible mode of transit. When a person is not at a destination and has reached a destination I update the one entity that matches that person and their expected mode of transit every couple minutes and otherwise they don’t update. Have never come close to the quota.
5 - Send yourself a notification
When my system things someone is going home and it has started to track their ETA I send myself a notification with the following:
- Who’s going home
- What’s their expected mode of transportation
- What’s their ETA
- Action to cancel (changes their “reached a destination” switch back to
off
)
Handy for debugging since you can double check it.
Also would recommend sending yourself a second one when your key action fires. For me that is when ETA <= “estimated minutes required to get house to correct temperature”. At that point I turn off eco mode and notify myself. For you that would likely be when ETA <= “time required to make coffee”.
6 - High accuracy mode is helpful
When trying to track an accurate ETA I found I needed higher accuracy on location then the default. So what I do is whenever the person is not at a destination I turn on high accuracy mode. Yes this drains battery more but I didn’t find it to be too bad, especially if you turn down the interval in the app’s settings a bit
Iphones don’t have a high accuracy mode so instead I send request_location_update
command every few minutes when they are not at a destination.
To reduce the drain on long drives or far away vacations, set a distance limit. Like if you’re >= 100 miles away from your house then go back to normal location tracking. There’s no reason to get an accurate ETA at that distance, worry about it once you get closer again.