Google Geocode Custom Component - GPS to Street Address

Need to figure out why it’s showing the wrong city.

@Coolie1101 I am aware of this issue. The component searches for two types of city, Postal_town and City. Postal_town should get used if there is no city but the component is picking the wrong one. This will be fixed in a future update.

No worries, it was meant as an FYI.

I have another update to the component today. I have added a few new features and fixed a few issues. I think I’m getting close to submitting this to become a home assistant component. You can get the new update on my GitHub.

New Features

Turn of Zone

You can now display an address at all times by turning off the zone. Check out the updated readme This can be done by adding display_zone: hide to the sensor config Thank you @dermicha for coming up with this idea.

More Sensor Attributes

I have added the following attributes, street number, county, formatted address. @coolie1101 as requested I have added street number to the attributes.

Fixes

City displaying as Postal Town

This issue is now resolved. Thanks @coolie1101 for pointing this out.

Formatted Address

Formatted address caused the sensor to fail. This has been fixed and now can be called as a sensor state with the option full. Check out the updated readme. Hope this helps @nick_12

Attributes when in zone

Attributes were not showing up when in zone. This has now been fixed. Thank you @ashfaaaa for pointing this out.

If there are any issues with this update please let me know. Thank you for all your support.

3 Likes

Thanks for the update :slight_smile: another feature maybe would be to display just the street until your stationary for X amount of time then show address.

1 Like

@nick_12 what you are talking about should be possible using templates. I have tried to put one together I can get it to work in the dev panel but it does not update after its first update. I cant seam to find an answer on how to get it to get further updates. This is what I have so far. Has anyone got any ideas?

600 is 10 minutes
Change sensor name to your sensor

- platform: template
  sensors:
    geocode_test:
      friendly_name: 'geocode test'
      value_template: >-
        {% if ((as_timestamp(now()) - as_timestamp(states.sensor.michael.last_changed)) | int) < 600 %}
          {{ states.sensor.michael.attributes.Street }}
        {% else %}
          {{ states.sensor.michael.attributes["Formatted Address"] }}
        {% endif %}

Thanks for the update.

On the frontend it shows not home, but in the attributes it shows the location, is this the way it’s supposed to work?

Do I need to use “display_zone: hide” to hide “not home” on the frontend?

@Coolie1101 Good spot. I have just update the master file on GitHub. It should fix the problem.

So, now I’m guessing I need to use a template sensor to get the street number to show up on the frontend?

Frontend:

Attributes:

wow. thanks for this amazing contribution.

can i request that, when I set display_zone: show, it will show the street address when the zone is “Not home”? The reason why I use this component is to display the person location when he/she is not at home or not at any zone.

@masterkenobi head back to my GitHub page the fix that I put in for @Coolie1101 should fix your problem.

@Coolie1101 yeah if you use templates to get the street number at the moment. What I might try and do is make a user selectable combination in the sensor yaml. I hadn’t thought of that before. I’ll have a look into it and see if it is possible.

1 Like

That’s the way it functions with the new update without the “display_hide” option.

yes. now it is perfect. thanks @michaelmcarthur!

Great, thanks for yet, another great addition.

1 Like

i use an android phone, for i using this component, i should install whitch device tracker? owntracks? gpslogger?

Yes. You need to use owntracks or similar app that include your GPS data in it. I’m using Zanzito.

1 Like

I’m using GPSLogger (ever since you gave me the tip :slight_smile:). Working great.

1 Like

New Feature

I have added a new feature asked for by @Coolie1101 and @nick_12 You can now specify what options you want to display as the sensor state. This can be done by using options.

options (Optional): Select what level of address information you want. Choices are 'street_number', 'street', 'city', 'county', 'state', 'postal_code', 'country' or 'formatted_address'. You can use any combination of these options, separate each option with a comma. The default is “street, city"

- platform: google_geocode
  name: michael
  origin: device_tracker.mobile_phone
  options: street_number, street, city
  display_zone: hide

This has added in street_number, county, postal_code and full has been replaced by formatted_address as available options.

Breaking Changes

full and both option will no longer work but can still be created by using formatted_address for full and street, city for both.

I think that is nearly all the feature requests made by the community. I would have loved to put place (shop, landmark) information in this component. It is not part of the google geocode api. It is part of the places api that requires a api_key. Due to this I wont be adding it. I have looked into wiki places which returns landmarks which is good in cities but soon as you get into towns or suburbs its useless. OpenStreetMap’s api is excellent and does provide shop and landmark information. I have been in contact with them to see if I can use their data, as the way it would be used would be against their usage policy.

Another feature I would have like to add was a link in the attributes to open a url to a map of the location. This has been confirmed as not possible at this time.

Any further issues or ideas please keep them coming.

4 Likes

Love this and got it setup.

I’m curious though if this info would be better as added attributes to the device tracker or yet another sensor.

Either way I love it and cant wait till its official!

@rabittn Thank you for your comment it’s appreciated. Another user came up with the same idea. I had a look into it and it would require updating every device tracker component to support this. Home assistant is built on components and it’s designed to be added to with sensors. This approach in future will allow users to decide which geolocation service they use. Be it google, openstreetmap or any number of services.