Google Geocode Custom Component - GPS to Street Address

Firstly, thanks so much for such a brilliant tool.

I’m using 4 APIs - 2 on my phone (1 for OwnTracks, One for Zanzito) and 2 on my Wife’s phone. I did try using the same API but kept getting messages to say I was over using the bandwidth. I commute 4 days out of 8, 60 miles / 100 minutes in each direction

Anyway - I’m up to 32,132 in the last 30 days

I’m happy to share any logs or other information which would help you in your development.

Hi guys. Sorry for my poor english. I have a tracker built using My Sensors. The sensor for this tracker does not have the longitude and latitude attributes. Instead it has a V_POSITION with “latitude,latitude,altitude” formatted info. I guess, that because of this, the geocode component does not work for me. It sticked to the “Waiting…” status and won’t change, even if the position changes…

below the attributes of my sensor:

battery_level: 0
child_id: 100
description: 
device: /dev/ttyUSB0
node_id: 10
V_POSITION: -22.xxxx,-43.xxxx,67
friendly_name: Position
icon: mdi:map-marker

I tried altering the code of the component, but I don’t know python and the Home Assistant stuff as well as you guys. :wink:

Is it possible, by any way, to adjust the code of this component to support My Sensor GPS info? Can any one assist or give me pointers on how to adjust the component?

Thank you.

EDIT: I found out today about the known_devices.yaml where the GPS sensor is listed. I changed the “track” attribute from “false” to “true” and the device_tracker sensor type was available. There is no need to change the code to support mysensors. :wink:

Hey peeps,
When I fill in the details in config.yaml and “Check Config” in hassio, the checking circle just keeps on looping.
If I restart HAssio anyway it doesn’t show any sensors

  • platform: google_geocode
    name: drthgfb
    origin: device_tracker.see
    options: street_number, street, city
    api_key: XXXX

Can someone please share an example of usage this component in groups.yaml?

My
sensors.yaml
- platform: google_geocode
origin: device_tracker.igor_adress
name: Where is

groups.yaml
family_people:
name: Кто дома?
view: false
icon: mdi:home-automation
entities:
- device_tracker.Igor
- google_geocode.igor_adress

But it doesn’t show any data.
How can I show current street for a person?

Log:
2018-07-14 20:54:07 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.where_is fails
Traceback (most recent call last):
File “d:\program\python\python36\lib\site-packages\homeassistant\helpers\entity.py”, line 196, in async_update_ha_state
yield from self.async_device_update()
File “d:\program\python\python36\lib\site-packages\homeassistant\helpers\entity.py”, line 319, in async_device_update
yield from self.hass.async_add_job(self.update)
File “d:\program\python\python36\lib\asyncio\futures.py”, line 331, in iter
yield self # This tells Task to wait for completion.
File “d:\program\python\python36\lib\asyncio\tasks.py”, line 244, in _wakeup
future.result()
File “d:\program\python\python36\lib\asyncio\futures.py”, line 244, in result
raise self.exception
File “d:\program\python\python36\lib\concurrent\futures\thread.py”, line 55, in run
result = self.fn(*self.args, **self.kwargs)
File "d:\program\python\python36\lib\site-packages\homeassistant\util_init
.py", line 318, in wrapper
result = method(*args, **kwargs)
File “d:\User.homeassistant\custom_components\sensor\google_geocode.py”, line 157, in update
zone_check = self.hass.states.get(self._origin_entity_id).state
AttributeError: ‘NoneType’ object has no attribute ‘state’
Thanks.

I have this in my groups:

  Family Locations:
    icon: mdi:account-multiple
    entities:
      - sensor.ian
      - sensor.ann
      - sensor.james

and in configuration.yaml:

sensor:
  - platform: google_geocode
    name: Ian
    api_key: <my api-key>
    origin: device_tracker.ian_samsung
    limit_refetch_to_url_change: true
  - platform: google_geocode
    name: Ann
    api_key: <my api-key>
    origin: device_tracker.ann_annsphone
    limit_refetch_to_url_change: true
  - platform: google_geocode
    name: james
    api_key: <my api-key>
    origin: device_tracker.james
    limit_refetch_to_url_change: true

The “origin” lines are from the known_devices.yaml

Hope this helps

1 Like

Hi,

I’ve just set this up and I have my project linked to billing which is telling me I have £232.80 credit left and 364 days.

I’ve tried disabling the billing and it restricts you down to 1 query per day.

Can I revert to some sort of free account with more than 1 query per day or when the trial runs out will I need to pay, still a bit confused on that part but other than that it’s all setup correctly!

Thanks,
Ed

@ewarwoowar keep an eye on how many requests you make. 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. You can view your updates on your google api dashboard. There is no need to disable billing as long as you stay within the limits.

Great work! :+1:

Mon Oct 08 2018 05:01:47 GMT+0200 (hora de verano de Europa central)

Update for sensor.google_geocode fails
Traceback (most recent call last):
File “/usr/local/lib/python3.5/dist-packages/homeassistant/helpers/entity.py”, line 223, in async_update_ha_state
yield from self.async_device_update()
File “/usr/local/lib/python3.5/dist-packages/homeassistant/helpers/entity.py”, line 352, in async_device_update
yield from self.hass.async_add_job(self.update)
File “/usr/lib/python3.5/asyncio/futures.py”, line 380, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.5/asyncio/tasks.py”, line 304, in _wakeup
future.result()
File “/usr/lib/python3.5/asyncio/futures.py”, line 293, in result
raise self._exception
File “/usr/lib/python3.5/concurrent/futures/thread.py”, line 55, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/local/lib/python3.5/dist-packages/homeassistant/util/init.py”, line 324, in wrapper
result = method(*args, **kwargs)
File “/home/pi/.homeassistant/custom_components/sensor/google_geocode.py”, line 157, in update
zone_check = self.hass.states.get(self._origin_entity_id).state
AttributeError: ‘NoneType’ object has no attribute ‘state’
some help?
thanks

Hello EveryOne,

First of all, thanks to the dev !
Now i’d like to understand google billing usage.
1/ I followed github instruction ( billing , api key ect ).
2/ The API is now used.
3/ i set quota on the google cloud platform as follow :

Premium plan web service requests per day 0
Premium plan web service requests per 100 seconds 0
Premium plan web service requests per 100 seconds per user 0
Premium plan Javascript API requests per day 0
Premium plan Javascript API requests per 100 seconds 0
Premium plan Javascript API requests per 100 seconds per user 0
Requests per day 18 600
Requests per 100 seconds 3
Requests per 100 seconds per user 3

I set quota in order to prevent any billing.
With quota, request ends with 403 error, without all is OK :frowning:

Any idea ?
thnaks

Is picture and icon customization not recognized?

I can’t seem to display a picture or an icon, only gravatar works.

I have made some changes for it to get the picture from the origin device_tracker component. I can upload that. @michaelmcarthur - This is a pretty useful component, do you plan to add it to Home Assistant? If not, I can do it and credit you.

You can add the following code in the @update section (line 150) . This will set the icon/picture whatever entity picture your original device tracker uses.

if self._gravatar is None:
            self._picture = self.hass.states.get(
                self._origin_entity_id).attributes['entity_picture']
1 Like

That’s a really nice simple piece of code. Thanks for contributing! I would love to see this component added to home assistant. I am happy with you submitting it.

So I’m throwing this in as described in the docs (placing the .py into the specific folder in my config, listing the correct platform and my correct origin entity on the sensor) but my log is throwing the following error:

2019-02-06 13:10:56 ERROR (MainThread) [homeassistant.loader] Unable to find platform google_geocode

Am I missing something?

The sensors in my config look like the following:

sensor:
  - platform: google_geocode
    name: Husband Address
    origin: device_tracker.husband_iphone_xs
    display_zone: hide
  - platform: google_geocode
    name: Wife Address
    origin: device_tracker.wife_iphone_7
    display_zone: hide

Nevermind. I’m an idiot. I put it in the < config >/www folder instead of the root config.

To use this I need to use an external device.traker like nmap or life360? Also when I get the API I need to pay something?

Hello, congratulations, your project is really interesting, even if I have not yet had the opportunity to test on my HA platform. One question: after registering on the google maps platform API platform, how much does the service cost after the free trial period? Your script necessarily requires the use of a Google email. Quite right?

I just upgraded from 0.91.4 to 0.92.0. Now google_geocode isn’t working anymore. I get this error message when I restart HA. This comes from checking the config:

Integration google_geocode not found when trying to verify its sensor platform.

I don’t have any ideas.

There was a breaking change to custom components a few releases back. Did you change your folder location?

If you still have platforms in your custom_components/ directory in the old file format, sensor/my_platform.py , rename it to my_platform/sensor.py . It still works but it will not be supported in a future release.