Show an address instead of long lat via device tracker

Anyone here know how I can get a physical address aside from the longitude and latitude shown by device tracker? I plan to hook it up to Alexa/Google Home, and make it respond to “Where’s my wife?”, and based on the GPS location it gets from device tracker, HA will reply “Your wife is on main street cor. maple street” or something like that.

Any ideas?

1 Like

Hey,

AFAIK this is not possible using “only” HA at the moment. The keyword you are searching for is reverse geocoding and google has an API for that. So you could write something in python which gets called from HA every 5 minutes and when your wife is not home and geocode her location and write it to a sensor using the REST API.

Helpful link: https://pypi.python.org/pypi/geocoder

~Cheers

Has anyone come up with a working solution to this? I don’t know Python quite well enough to code this for myself.
Any help would be appreciated!

I’m not very good with writing code myself, however I did notice that in the dependencies folder there is already a geocoding.py file within the googlemaps folder. So that might give an enterprising coder a good start for this I would hope.

I made a sensor that reports a readable address for Alexa. I use a find and replace later to change AVE to Avenue etc. Here is the bit of php code that translates to major intersections.

$url = "http://geocoder.ca/?latt=".$lat."&longt=".$long."&corner=1&geoit=xml&range=&reverse=Reverse+GeoCode+it%21&json=1";
$data = json_decode(file_get_contents($url), true);
$street1 = $data['major_intersection']['street1'];
$street2 =  $data['major_intersection']['street2'];

I have made a custom component that displays a street name from a device trackers location. You can check it out here.

Here is a screenshot of it in action.

2 Likes

…and I’ve also made one that returns address, place name and place type as well as direction of travel and distance from home using OpenStreetMaps that does not require registering for an API key…

Can you update your integration to display the actual longitude and latitude values from the device tracker? Or better still, create/generate a sensor or an entity for longitude and another for latitude?
This would be very helpful for people (like me) who need the actual coordinates, not the address… It would make your integration more comprehensive…