Knowing when someone will arrive home can be surprisingly useful in a smart home. With a commute of over an hour, I like to keep my partner up to date about my expected arrival time. It definitely helps with timing dinner. 😉
In my setup I use the Home Assistant together with the Google Travel Time Integration to calculate travel time from my current location to home.
However, the Google API has usage limits. If you continuously update the travel time sensor every minute, those limits are quickly reached. So instead I built a small system that only updates travel time when I’m actually travelling home. This keeps API usage low while still providing accurate arrival estimates.
In this article I’ll walk through the complete setup.
How the Travel Time System Works
The idea behind the automation is simple and efficient:
- When I leave work, Home Assistant updates the travel time to my home.
- A notification is sent with my expected arrival time.
- A helper boolean (
travelling_peter) is turned on. - While the boolean is turned on, the travel time is updated every five minutes.
- When I arrive home, the system automatically stops updating.
- The dashboard shows my expected arrival time and current location.
This approach prevents unnecessary API calls while still keeping the arrival estimate up to date.
Detecting When I Leave Work
The first automation triggers when I leave the work zone. When this happens:
- The travel time sensor is updated
- A notification is sent
- The travelling boolean is enabled (make sure to create it first!)
- id: travel_to_home
alias: "Travel: On the way home"
initial_state: 'on'
trigger:
- platform: zone
entity_id: person.peter
zone: zone.werk
event: leave
condition:
- condition: time
after: '14:00:00'
before: '19:00:00'
action:
- service: homeassistant.update_entity
target:
entity_id: sensor.travel_time_peter
- delay: "00:00:10"
- service: notify.all_devices
data:
title: "Peter is on the way home!"
message: >
Peter has a travel time of {{ states('sensor.travel_time_peter') }} minutes.
He will arrive around
{{ (as_timestamp(now()) + 60 * states('sensor.travel_time_peter') | float(0))
| timestamp_custom('%H:%M') }}.
- service: input_boolean.turn_on
target:
entity_id: input_boolean.travelling_peterThe small delay ensures the sensor has updated before the notification is generated.
Updating Travel Time Every Five Minutes
Traffic conditions can change during the trip, so the travel time should be refreshed occasionally.
Instead of updating continuously, I refresh the sensor every five minutes, but only while the travelling boolean is active.
- id: travel_update_peter
alias: "Travel: Update travel time Peter"
initial_state: 'on'
trigger:
- platform: time_pattern
minutes: "/5"
condition:
- condition: state
entity_id: input_boolean.travelling_peter
state: "on"
action:
- service: homeassistant.update_entity
target:
entity_id: sensor.travel_time_peterThis keeps the ETA accurate while minimizing API calls.
Detecting When I Arrive Home
Once I arrive home, there’s no need to keep updating the travel time.
A simple automation disables the travelling mode.
- id: travel_arrived_home
alias: "Travel: Arrived home"
initial_state: 'on'
trigger:
- platform: zone
entity_id: person.peter
zone: zone.home
event: enter
action:
- service: input_boolean.turn_off
target:
entity_id: input_boolean.travelling_peterShowing the Arrival Time on the Dashboard
On my dashboard I display the expected arrival time using a Markdown card.
The message only appears while I’m travelling.
type: markdown
content: |
## Hello {{ user }}
{% if is_state('input_boolean.travelling_peter', 'on') %}
<ha-icon icon="mdi:car-sports"></ha-icon> Peter will be home around **{{ (as_timestamp(states.sensor.travel_time_peter.last_updated) + 60 * states('sensor.travel_time_peter') | float(0)) | timestamp_custom('%H:%M') }}**
{% endif %}Because the travel time sensor is refreshed every five minutes, the dashboard automatically updates with the newest estimate.
Manually Sending a Travel Notification
Sometimes I’m travelling somewhere other than work, or I simply want to notify home manually.
For this I created a dashboard button that triggers the same automation.
type: conditional
conditions:
- condition: state
entity: person.peter
state_not: "home"
card:
type: button
entity: automation.travel_to_home
show_icon: false
name: Send travel time notification
tap_action:
action: perform-action
perform_action: automation.trigger
data:
skip_condition: true
target:
entity_id: automation.travel_to_homePressing the button simply triggers the automation and sends the travel update.
I’ve also considered placing an NFC tag within my car which I can use to send a notification.
Showing My Location on a Map
Finally, I added a map card showing my current location relative to home.
The card is only visible while I’m travelling.
type: conditional
conditions:
- entity: input_boolean.travelling_peter
state: "on"
card:
type: map
auto_fit: true
entities:
- person.peter
- zone.homeThis allows anyone at home to quickly see how far away I am.
Why This Approach Works Well
This setup has proven to be a simple but very practical automation. It offers several advantages, like accurate arrival times.
And because everything is based on travel time, it becomes very easy to extend this automation. For example, you could turn on lights, enable the coffee machine or anything else based upon travel time rather than distance.
Thanks for making this post! I really want to try out something similar. But what about the costs of this Google Travel Time service? Because I read before that people got surprised because of it.
Hi! See https://www.home-assistant.io/integrations/google_travel_time/
There are about 10.000 free requests a month, so thats a bit more than 300 requests a day. If you manually update the travel time, you can kinda figure out if you will be reaching that limit.
For me personally, I dont travel more than 2 hours a day in which my travel need to be updated. So with a 5 minute gap, that’s only 24 requests a day 🙂