Reverse geocoding generates an address from a latitude and longitude of device tracker.
Note: Home Assistant's Companion App provides a built-in Geocoded Location sensor that performs reverse geocoding on-device using Apple/Google services. This integration differs by using OpenStreetMap Nominatim server-side, which gives you full control over the output format via Jinja2 templates, consistent results across all device types, richer address detail from OSM data, and works with any
device_trackerentity -- not just Companion App devices. For example, OSM data includes nearby point-of-interest names like store names (e.g. "Lidl, Piątkowska 64, Winiary, Poznań") that native geocoding typically omits.
Inspired by GoogleGeocode-HASS.
- Add custom repository in HACS settings tab. Select
Integrationcategory. - Search for and install the "OSM Geocode" integration.
- Restart Home Assistant.
- Copy
custom_componentsinto the config directory of your Home Assistant installation. - Restart Home Assistant.
sensor:
- platform: osm_geocode
name: Location Sensor Name
source: device_tracker.source_device_tracker
source (Required): device_tracker that produces latitude and longitude
name (Required): A name to display on the sensor
scan_interval (Optional): The frequency of scan in seconds. Default: 60.
icon (Optional): Icon to display. Default: "mdi:map-marker".
template (Optional):
Possible attributes: category, type, importance, addresstype, name, display_name, address, house_number, road, city_district, city, county, state, postcode, country, country_code,
Default:
{% if zone %} {{ zone }} {% else %} {% if name %} {{ name }}, {% endif %} {{ house_number }} {{ road }}, {{ city_district }}, {{ city }} {% endif %}

