Code Monkey home page Code Monkey logo

googlegeocode-hass's Introduction

Google Geocode

This component has been created to be used with Home Assistant.

Google geocode is the process of converting device tracker location into a human-readable address.

The sensor will update the address each time the device tracker location changes. If the device tracker is in a zone it will display the zone.

Installation:

Copy the manifest.json file and place it in <config_dir>/custom_components/google_geocode/manifest.json

Copy the sensor.py file and place it in <config_dir>/custom_components/google_geocode/sensor.py

Example Screenshot:

alt text

Example entry for configuration.yaml

sensor:

  - platform: google_geocode
    origin: device_tracker.mobile_phone

Configuration variables:

origin (Required): Tracking can be setup to track entity type device_tracker. The component updates it will use the latest location of that entity and update the sensor.

name (Optional): A name to display on the sensor. The default is “Google Geocode"

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"

display_zone (Optional): Choose to display a zone when in a zone. Choices are 'show' or 'hide'. The default is 'show'

gravatar (Optional): An email address for the device’s owner. You can set up a Gravatar here. If provided, it will override picture The default is 'none'

api_key (Optional): Your application’s API key (get one by following the instructions below). This key identifies your application for purposes of quota management. Most users will not need to use this unless multiple sensors are created.

You need to register for an API key to use Google Geocode. This can be done by following these instructions

  • 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.

Example with optional entry for configuration.yaml

- platform: google_geocode
  name: michael
  origin: device_tracker.mobile_phone
  options: street_number, street, city
  display_zone: hide
  gravatar: [email protected]
  api_key: XXXX_XXXXX_XXXXX

googlegeocode-hass's People

Contributors

michaelmcarthur avatar wonderslug avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

googlegeocode-hass's Issues

Integration google_geocode not found

Thanks for the great plugin,
I'm running my HA on Docker. And copied the manifest and sensor to /custom_components/google_geocode/ (and for safety in /config/custom_components/google_geocode/ )

I've configured an API key for the following API's because your description is different from my steps.

Maps JavaScript API
Geocoding API
Places API

I've ensured that the billing profile is ok.

My configuration.yaml is exacty like yours (I've put in my own entity and api key)

  • platform: google_geocode
    origin: device_tracker.sm_a520f
    options: street_number, street, city
    display_zone: hide
    gravatar: <my_email>
    api_key: <my_api_key>

But I'm getting the following error after restarting my HA server:

Platform error sensor.google_geocode - Integration 'google_geocode' not found.

Can you get me further?

Attributes not showing when zone.

Attributes are not shown when in a zone. This is because the component only checks google when a device_tracker is not_home. This should only called once for each zone. This will save on requests.

Check if options entered are allowed

Need to create a check to see if the user entered option is an allowed option e.g. street, city. If it is not create warning to tell the user to check their config.

Person component integration

The recent HA version introduced new component to make device_tracking association with users even more easier. https://www.home-assistant.io/components/person/

The component object seems to have same attributes for longitude and latitude but unfortunately google_geocode doesn't return any response when the person object is passed as origin. Any chance for implementation?

remove old entities?

I can't seem to find where old entities generated from this integration are located. They are not in the entity registry and cannot be remove via the Gui.

Can you advise on how to force delete?

[REQUEST] Add localization option

Hi,

I know it's possible to get localized info from Google APIs.
It would be very nice if you could add an option for selecting localization language to get the results in a translated form.
Something like:

   locale: EN
   locale: PL

Best regards
Szafran

Prepare component for pull to hass

If anyone can share what needs to be done to get this component added to home assistant.

Code will have to be tidied up. All issues need to be resolved first.

Add Entity Picture Option

User @prates said

Excelent!
Used for just one day, and got the api limit error. Just got an API key to see if fix this. Also missing an option to choose a picture: it seems that picture or entity_picture doesn´t work as it does for device_tracker.

Add entity_picture as option

Platform not found: sensor.google_geocode

Dear Michaelmcarthur,

I found your option to make location update by adress and zones for home assistant.
I have followed your instructions but after I have made the directory config/custom_components/sensor/ and copied the file google_geocode.py into that map and i validate my configuration i get the following error: "Platform not found: sensor.google_geocode".

Can you help me out solving this error.

Thanks NeuzNL

No 'version' key in the manifest

Logger: homeassistant.loader
Source: loader.py:786
First occurred: 3:34:29 PM (1 occurrences)
Last logged: 3:34:29 PM

No 'version' key in the manifest file for custom integration 'google_geocode'. As of Home Assistant 2021.6, this integration will no longer be loaded. Please report this to the maintainer of 'google_geocode'

howto connect this to a person

person:

  • name: Ada
    id: ada6789
    device_trackers:
    • device_tracker.ada

can only add trackers there. not entity (sensor.) that this seems to create.

No box in frontend with adress !!

Hi

Thanks for sharing this great little tool that I have setup in my own HA and so far it looks to work excepted one thing: I have well a new round icon with my name and gravatar icon and when I click on it I can see current adress and history, but I don't have the square box appears with name and adress as displayed in your setup ! Did you do something extra ? Running on HA 0.51.2

My config:

- platform: google_geocode
    name: vincen
    origin: device_tracker.vincen_mqtt
    options: street_number, street, city, country
    display_zone: show
    gravatar: !email
    api_key: !google_geocode_api

Thanks

Vincèn

Unable to use !tag for geocode and email !

For security and ease of maintenance I store all sensible credentials in a separate secrets.yaml but it doesn't work for gravatar and api_key of your module ! HA complains it doesn't recognise unless it works with all other plugins, and configuration directive in my configuration.yaml file !

Vincèn

Formatted Address Fail

Searching for formatted_address in the json stops the sensor from working. When it does work it sometimes displays a different street from the returned street name.

Full option has been removed at this time.

Notify @nick_12 when this is fixed.

Api limit reached

Api limits are reached if device tracker updates frequently. This could be resolved by adding the option of adding an api key.

'Awaiting update' when inside a zone

When configuring home assistant using the yaml files we are often restarting the instance. I noticed that when I do this – most of the time I am at home – it will say 'Awaiting update' because then I don't move my device and owntracks doesn't provide new location data.
But since I am in a hass zone (home or work or whatever) shouldn't it use these coordinates instead?

Imgur

Errors at startup

Everytime i am forced to restart HA i get always the same errors:

Questo errore ha avuto origine da un'integrazione personalizzata.

Logger: homeassistant.helpers.entity
Source: custom_components/google_geocode/sensor.py:156
Integration: google_geocode (documentation)
First occurred: 11:56:37 (6 occurrences)
Last logged: 11:58:37

Update for sensor.fha fails
Update for sensor.maurizio fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 554, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 781, in async_device_update
    await hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 190, in wrapper
    result = method(*args, **kwargs)
  File "/config/custom_components/google_geocode/sensor.py", line 156, in update
    zone_check = self.hass.states.get(self._origin_entity_id).state
AttributeError: 'NoneType' object has no attribute 'state'

Is there a way to fix this?

User defined format of address component

@mcfrojd1d

Another bug,
street_number, street, city or street, street_number, city gives the same result.
(number, street, city)

Look into displaying in the same order as the user has entered into the yaml

Add Geocoding API to setup instructions

Thanks for this great component!

Took me a few minutes to figure out why I couldn't get it to authorize my requests. I eentually figured out that I need to enable the Geocoding API where as the readme only mentions Maps and Places

Perhaps adding that would help other new users?

Hebrew lang

hi,
in old version of this componet i was able to change the lang to hebrew by
" got it to work in hebrew…
in the google_geocode.py file
you need to change:
url = “https://maps.googleapis.com/maps/api/geocode/json?latlng=” + lat + “&key=” + self._api_key

to

url = “https://maps.googleapis.com/maps/api/geocode/json?latlng=” + lat + “&key=” + self._api_key + “&language=iw&region=IL”

And you will get the address in Hebrew.
you can select whice language and region by changing the parmeters"

now i cant, can you help?

api instructions dosnt work?

get this error

Logger: homeassistant.components.websocket_api.http.connection
Source: components/hassio/init.py:599
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 20:05:00 (4 occurrences)
Last logged: 20:31:31

[281472931109376] The system cannot restart because the configuration is not valid: Platform error sensor.google_geocode - Integration 'google_geocode' not found. Platform error sensor.google_geocode - Integration 'google_geocode' not found.
[281472921613840] The system cannot restart because the configuration is not valid: Platform error sensor.google_geocode - Integration 'google_geocode' not found. Platform error sensor.google_geocode - Integration 'google_geocode' not found.
[281472921825232] The system cannot restart because the configuration is not valid: Platform error sensor.google_geocode - Integration 'google_geocode' not found. Platform error sensor.google_geocode - Integration 'google_geocode' not found.
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 185, in handle_call_service
await hass.services.async_call(
File "/usr/src/homeassistant/homeassistant/core.py", line 1495, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1530, in _execute_service
await handler.job.target(service_call)
File "/usr/src/homeassistant/homeassistant/components/hassio/init.py", line 599, in async_handle_core_service
raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: The system cannot restart because the configuration is not valid: Platform error sensor.google_geocode - Integration 'google_geocode' not found.
Platform error sensor.google_geocode - Integration 'google_geocode' not found.


have created api key.. but the instructions isnt really as the plattform

instructions sas
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.
__

but there isnt any Maps API?
enabled all these
Geocoding API
Geolocation API
Maps Elevation API
Maps Embed API
Maps JavaScript API
Maps Static API
Places API

But there arnt any request to any of em?

Api called if in zone.

Api continues to make requests when in a zone. E.g. When in home once first request has been made there is no need for further calls until a change of zone or not_home.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.