Google Geocode Custom Component - GPS to Street Address

I’ve been using my own version of a Reverse Geocode sensor for a few months now based on OpenStreetMap data and I’m finally ready to share it with anyone who might find it useful.

Apart from returning the “Place Name”, “Place Type”, “Address”, “Neighborhood”, etc. It calculates a user distance from home and whether they are traveling “towards home”, “away from home” or “stationary”. Multiple users can have unique home zones defined for them. It also generates a link for Google Maps or Apple Maps that can be sent with a notification and clicked to open the users location on a map.

I’ve written a description of it here:
[Reverse Geocode Sensor ("Places") using OpenStreetMap - custom component]

The custom component itself - and more details about it - is available here to anyone that cares to try it. It’s been stable and working well for my family for over a month now.
[https://github.com/tenly2000/HomeAssistant-Places]

1 Like

Your component looks very good. I’m impressed with the extra features you have adddd.

Hi Michael
Thanks again for this grate component i use it with my google API and zanzito it works without fail.
Just wanted to ask you a question about the changes on google maps, will this affect how the api works.
They are changing the way the API works from Jun 11 they will require to have an account and billing activated for the api to work. They do include (a free) $200 per month as credit, i assume that will be more then enough for a normal usage.
I just receive this email today, just wondering if you got one to, or not.

I wanted to ask exactly the same question. Google said that for my use case the free tier of $200 would be insufficient.

@tenly doe you know what the API restrictions are using OpenStreetMap? Your component does indeed look impressive.

1 Like

I got the same email. I am planning to post an update on this issue once I have looked into it. I run two device trackers and google said that I would be covered by the free $200 limit.

The component will be updated over the next month to reflect the changes that google are making.

1 Like

@tenly Yes, this does look interesting.

What is the map_link for? How can you use it? I thought maybe I could feed it into a camera component but i couldn’t get it to work.

Also, the api email is optional but do you know how many calls you can make without it?

Thanks.

I am using on 2 phones and and i am ok on $200 limit to.

Thanks again Michael for all the hard work on creating and maintaining this component.
You have all my respect.

Thank you! As you know, I took inspiration from your component and used your component as my guide for learning how to create a custom component.

Hi Geoffrey,

I don’t know what the limits are. But with the OpenStreetMap api, it’s not a true api key that is required - it’s just an email address. I am tracking 3 users 24/hours per day and I’m supplying a different email address for each user.

My component also caches the last lat/long from DeviceTracker so it can check distance travelled since last update. It ignores distance changes < 10m and only makes the call to OpenStreetMap when required. This should reduce the number of calls to the API - although, on weekends, when everybody is moving around a lot - I do get quite a few notifications.

Hi Klogg,

I use the map_link in notifications that I send so that I have a quick link to click on to look at where the person is and what else is in that area. For a while, I used a google link that automatically calculated directions for the user to get home from - or for me to get to them - but that got annoying more often than not, so I reverted back to just a map centered on the users current location. Map_zoom is a configurable option you can use in conjunction with map_link if you want to see more or less of the users surroundings.

Thanks, that makes sense with sending a link to the map in a message.

I only discovered both of these components today. I tried the google one and for some reason sometimes it worked and sometimes it didn’t because it said I had exceeded the usage allowance. But it was inconsistent, not always one or the other.

I assume you mean the zoom is configurable in that you can alter what is sent in the link? There is no way to show the map in HA. Right?

The Home Assistant iOS app is already capable of displaying a map in a notification if you pass the latitude and longitude to it (see the iOS notification documentation for details). I started off using that in my notifications, but it was static and I couldn’t control the zoom level on it. It would have been ideal if it was a clickable link that would open the same location in the Maps app - but the developer of the iOS Home Assistant app did not respond to any of my questions - so I went this route instead.

In my situation the 200$ should not be sufficient google told me :frowning:
So Is there a way to manually update the traveltime sensor so the api requests decreases?

And does anyone know if you can set a limit so you dont get a high bill if you accidentally exceeds the 200$ limit?

1 Like

I had a look into the changes Google are making. Most users should not be charged anything for using my component. You can review the pricing structure here. For geolocation the free allowance is 40000 calls a month. That works out as 1290 calls a day. Over the last 30 days one of my trackers only updated 380 times. Google is now calling their API ‘Google Maps Platform’ which includes Maps, Route and Places. A user could exceed the free allowance if they are using the api key for other maps services.

I have added step by step instructions on how set up billing to the readme on Github. Here are the steps

  • Go to Google Maps Platform API
  • Click on ‘Get Started’
  • Select ‘Maps’ and ‘Places’ then click ‘continue’
  • Create a new project or select an existing one then click ‘next’.
  • Clcik ‘Create Billing Account’
  • Create a name for the account then click ‘Continue’
  • Confirm your Country then click ‘Confirm’
  • Fill in your detail the click ‘Submit and enable billing’
  • To Emable your API’s Click ‘Next’
  • Copy your API key.
2 Likes

Out of interest could you check your api dashboard to see how many requests the Geocoding API is using over 30 days? It can be done by clicking here.

2 Likes

Thanks thats good to know

8,137 requests for me using two devices (iPhone 7+ and Pixel 2 XL using custom Google Maps device tracker).

I finally got a chance to take a look at this today. I work from home most of the time, but it dawned on me today that I could use a GPS Spoofer on my Android phone. When I did that and set my location to locations where I normally go, the furthest ‘nearby’ location I got was 0.1 and most were within feet.

With the changes by Google to the API, I’ll have to keep an eye on it though. Since I’m using the Places, Geocoding, and Distiance Matrix API’s, I’ll have to see what the usage I end up with.

Capture2Capture3CaptureCapture4Capture5

The last 30 days it uses 11200 requests. Its for two devices

I have 25152 requests using my phone as a device tracker using the OwnTracks HTTP integration

Does anybody else use a phone as a device tracker with this component?