Mastering Hyper-Local Intelligence: Integrating Advanced Location Services (HERE & OpenStreetMap) with Home Assistant

NGC 224
DIY Smart Home Creator
Mastering Hyper-Local Intelligence: Integrating Advanced Location Services (HERE & OpenStreetMap) with Home Assistant
Beyond basic presence detection, a truly intelligent smart home anticipates your needs. This guide shows how to integrate advanced location services like HERE Maps and OpenStreetMap (OSM) with Home Assistant, enabling proactive automations based on precise travel times and contextual location data.
The Power of Mapping Services
While Home Assistant's device trackers show current location, mapping services add crucial dimensions: distances, travel times, and geocoding (converting addresses to coordinates and vice-versa).
- HERE Maps: Offers highly accurate routing, real-time traffic, and comprehensive geocoding, ideal for precise travel time estimations.
- OpenStreetMap (OSM): A collaborative, open-source project. Its free-tier APIs (like Nominatim) are great for general geocoding and privacy-centric data, though with rate limits.
Core Concepts: Device Tracking & Travel Time
Ensure you have a reliable device_tracker
setup in Home Assistant (e.g., using the Companion App). Home Assistant's travel_time
integration then calculates travel duration between two points using providers like HERE.
Setup Guide: HERE Travel Time Integration
HERE Maps offers a free developer tier. You'll need an API key.
1. Obtain a HERE API Key
- Go to developer.here.com and sign up.
- Create a new project and generate a REST API key. Keep it secure.
2. Configure HERE Travel Time in Home Assistant
Add to your configuration.yaml
. Replace YOUR_API_KEY
and define your origin/destination:
sensor:
- platform: here_travel_time
api_key: YOUR_API_KEY
name: Travel Time Home to Work
origin: zone.home
destination:
- latitude: 34.0522
longitude: -118.2437 # Example: Work Address Coords
units: metric
travel_mode: car
options: ['traffic_mode', 'fastest']
- platform: here_travel_time
api_key: YOUR_API_KEY
name: Travel Time Person A to Home
origin: device_tracker.person_a_phone
destination: zone.home
units: metric
travel_mode: car
options: ['traffic_mode']
Restart Home Assistant. Sensors like sensor.travel_time_home_to_work
will provide estimated travel durations.
Setup Guide: OpenStreetMap (OSM) for Geocoding
OSM's Nominatim service excels at geocoding/reverse geocoding. While no direct flexible integration exists, you can use Home Assistant's built-in geocoded_location
or a custom REST sensor.
1. Using Home Assistant's Geocoded Location
This integration resolves addresses to coordinates. Add it via Settings > Devices & Services > Add Integration, search for "Geocoded Location". You can then call the service geocoded_location.geocode
(e.g., in automations).
service: geocoded_location.geocode
data:
address: "1600 Amphitheatre Parkway, Mountain View, CA"
response_variable: geocoded_data
2. Custom REST Sensor for OSM Nominatim (Advanced)
For more dynamic reverse geocoding (e.g., converting a device_tracker
's coordinates to a human-readable address), use a REST sensor. Be very mindful of Nominatim's usage policy and rate limits. Set a generous scan_interval
(e.g., 300
seconds or more).
Advanced Use Cases
1. Dynamic Arrival/Departure Automations
Trigger actions based on travel time. E.g., pre-cool your home when sensor.travel_time_person_a_to_home
drops below 15 minutes.
alias: 'Pre-cool Home Before Arrival'
trigger:
- platform: numeric_state
entity_id: sensor.travel_time_person_a_to_home
below: 15
condition: "{{ is_state('climate.thermostat', 'off') }}"
action:
- service: climate.set_hvac_mode
target: { entity_id: climate.thermostat }
data: { hvac_mode: 'cool' }
mode: single
2. Route Optimization Notifications
Alert if commute time significantly increases due to traffic.
alias: 'Commute Traffic Alert'
trigger:
- platform: numeric_state
entity_id: sensor.travel_time_home_to_work
above: 45
condition:
- condition: time
after: '07:00:00'
before: '09:00:00'
action:
- service: notify.mobile_app_your_phone
data:
message: "Heads up! Commute to work is {{ states('sensor.travel_time_home_to_work') }} mins."
mode: single
3. Contextual & Custom Geo-fencing
Combine device tracking with reverse geocoding to know the *type* of place a person is at (e.g., 'at the park'). For complex geo-fencing, consider custom REST sensors interacting with services that support polygonal zones.
Best Practices for Reliability
- API Key Management: Use Home Assistant's secrets.yaml for all sensitive credentials.
- Rate Limits & Privacy: Be mindful of API usage limits (especially for Nominatim). Consider privacy implications of sending location data to cloud services. Adjust
scan_interval
for REST sensors to avoid issues. - Error Handling & Fallbacks: Use
default()
in Jinja2 templates (e.g.,value_json.address.road | default('Unknown')
) to prevent errors. Ensure core automations still function if an external API fails. - Combine Data Sources: Utilize multiple device trackers for improved accuracy and resilience.
- Performance: Avoid excessive API calls. Request data only when necessary.
Conclusion
Integrating HERE Maps and OpenStreetMap transforms your Home Assistant from reactive to truly intelligent. By understanding real-time travel patterns and contextualizing locations, you create proactive, intuitive automations that genuinely enhance your smart home experience. Embrace hyper-local intelligence and redefine what's possible.

NGC 224
Author bio: DIY Smart Home Creator